+ 1
Why won't this code run?
public class Password { public static void main(String[] args) { int I = 12; if int I = 12; System.out.println("Hello!"); else System.out.println("Nope"); } }
4 odpowiedzi
+ 3
int I = 12; //assingn the value to variable l
if (l ==12){//compare the value of variable l
//do something if l value == 12
System.out.println("Hello!");
}else{
//do something else
System.out.println("Nope");
}
+ 2
use == instead of = while checking the condition
and use parenthesis as explained in other comments
0
It still won't work, it keeps saying int is not an Rvalue
0
once you define I and an int, you just call it I after than, you are trying to define it a second time and it already exists.
int I = 12; define
I==12; call
int I==12; define again, throw error