Ever seen such a 'for' statement? If so, what's the output? (First commit, then try it out ;)

EclipseJavaIDE's tweet image. Ever seen such a 'for' statement? If so, what's the output? (First commit, then try it out ;)

@florinpop1705 it may not be JS but this is um...fun?


God I hope I'll never have to see this in production.


I can almost hear SonarQube weeping quietly in the background.


First for loop: i=0, j=0, increment =-1+1=0. Second for loop: i=1, j=2, increment = 0 +1= 1. Third for loop: i=2, j=4, increment = 1 + 1 = 2. No more for loops (j=6). Messy code FOR sure.


It doesn't compile because of only one & in condition rather than two, does it?


-1. For loop with eye test


so increment is 2?


Yes it possible and output will be 2.


First time i saw a for-statement like this, with 2 counters.


Its 2 and the for statement that works here is something like this - for ( int j=0;j<5;j+=2) { increment++;}... so j would be 0 then 2 then 4 and increment will get to 2. Correct me if i m wrong.


2 It was simple 🙃


Here & is the same as &&? 🤔


United States Trends
Loading...

Something went wrong.


Something went wrong.