my dog learned polymorphism
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes continue blues 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 "continue blues" Watch "continue blues" New topic

continue blues

bobby chaurasia
Ranch Hand

Joined: Mar 30, 2002
Posts: 84
public static void main( String args[] )
for(int ii = 0; ii < 3; ii++) {
for(int jj = 3; jj <= 0; jj--) {
if(ii == jj) continue;
System.out.println(ii + " " + jj);
The correct answer the following code is
The program does not print anything.
I thought that each time ii == jj condition is true, it goes to next jj ie jj-- without printing ii and jj. But in other situations where ii is not equal to jj it should print ii & jj. Any clues ?
[ April 20, 2002: Message edited by: bobby chaurasia ]
Sharon Miller

Joined: Mar 25, 2002
Posts: 10
HI Bobby,
If you take a look at the test condition for the inner loop of the nested for loop, you will realize why nothing is printed.
Perhaps if it is changed to the following

The above code probably works as per your expectation.
A suggestion would be to compile and execute the original code to validate your assumptions.
I agree. Here's the link:
subject: continue blues
It's not a secret anymore!