Jump to content

Continue (Java)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mako 5 (talk | contribs) at 07:16, 13 December 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The continue keyword works in Java in the same way that it does in C and C++. When used inside of while and for loops where when it is called, will skip the remaining instructions in the loop and begin on the next iteration in the loop.

//The following only prints even numbers for(int i=0; i<10; i++) {

   //skips the print statement if i is not even
   if(i % 2 != 0)
       continue;
   System.out.println(i);

}