+ 1

Explain this to me

int x=1; int y=2; for(;;){ System.out.print((x++)+(++y)); if(x>3) break; } o/p : 468

14th Jul 2017, 12:10 PM
Amit
Amit - avatar
1 Answer
+ 1
1) First it creates two numerous values one called 'x' and another called 'y' @line 1-2 2) From there it creates an endless for loop @4-8 3) in loop print the value of x + the value of y + 1(+1 is because of the ++ before the y). @ line 5 4) add 1 to x(because ++) @ line 5 5) if the value of x is bigger then 3 break out of the loop. And end subsequently exacution.
14th Jul 2017, 1:00 PM
josh mizzi
josh mizzi - avatar