0

Help!! As always lol, it would be awesome if someone explains the behavior of this code

int x =1; if(x++ <= 1 && ++x > 2) System.out.println("a"); System.out.print(x);

23rd Jul 2018, 7:13 AM
ralph
ralph - avatar
2 Réponses
0
I think something is missing: "{" behind if(x++ <= 1 && ++x > 2) and "}" before System.out.print(x); int x =1; if(x++ <= 1 && ++x > 2){ System.out.println("a"); System.out.print(x); } output: a 3 explaneation: int x = 1; // make variable type int equal 1 if(x++ <= 1 ..... // check or variable x is less or equal 1 than add 1 ..... ++x>) // add 1 to x than check or variable x is greater than 2 if(x++ <= 1 && ++x > 2) // check or both conditions are true when yes: System.out.println("a"); // print letter a System.out.print(x); // print value x
23rd Jul 2018, 8:03 AM
Dawid
Dawid - avatar
0
thank you my friend
23rd Jul 2018, 8:14 AM
ralph
ralph - avatar