Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Operators

 
mohit joshi
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for(int j=0,k=0;j<10&&k<10;k+=++j==10?1+(j=0):0)

System.out.println( " k "+k+", j "+j);
guess what the above code does?
[This message has been edited by mohit joshi (edited November 17, 2000).]
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting little piece of code. At first glance I thought it would cause an infinte loop, but I can see why it gives the output it does. However, in the sake of readability, if any of the programmers I work with did that, I would have to kill them.
 
Peter Lyons
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It gives me a headache?
 
mohit joshi
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please dont kill me, I am only experimenting with operator precedence
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic