Why does it give me error? Some explain why i cant store the user input into an int and why i cant use the scanner as a boolen*
4 Answers
New Answerpublic static void main (String args[]){ Scanner y= new Scanner (System.in); System.out.println(y.nextInt()); int z=y; int x= 1; if (z = x){ System.out.println("hello");} else {System.out.println ("nope");} } *even tho im using an if loop. I mean the loop is kinda true/false so maybe the program is reading it as a boolen. Please i need an explanation it would help me alot. Thanks in advance :)
5/12/2019 3:29:08 AM
Victor Tonna4 Answers
New AnswerVictor Tonna If you plan to show your code in a thread, please make sure that it is void of profanities.
Line 12: if(z==X). <- double equal to sign = Assignment == Comparison Line no. 7 Scanner y= new Scanner (System.in); z = y.nextInt(); Remove line no. 9 and write line no. 7 and 8 in one line
Also sorry for the strong language . i was testing my self and didnt think i was going to share this code so please dont get offended. Tks :)
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message