File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Operators" Watch "Operators" New topic


mohit joshi
Ranch Hand

Joined: Sep 23, 2000
Posts: 243
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

Joined: Jun 30, 2000
Posts: 1070
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

Joined: Sep 12, 2000
Posts: 202
It gives me a headache?
mohit joshi
Ranch Hand

Joined: Sep 23, 2000
Posts: 243
please dont kill me, I am only experimenting with operator precedence
I agree. Here's the link:
subject: Operators
It's not a secret anymore!