0
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*
public 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 :)
4 Respostas
+ 5
Victor Tonna If you plan to show your code in a thread, please make sure that it is void of profanities.
+ 2
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
0
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 :)
0
Hatsy Rei yes im sorry. It will not happen agian.