Java Programming/Keywords/break

From Wikibooks, the open-content textbooks collection

< Java Programming | Keywords
Jump to: navigation, search

break is a Java keyword.

Jumps (breaks) out from a loop. Also used at switch statement.

For Example:

for ( int i=0; i < maxLoopIter; i++ )
{
   System.out.println("Iter=" +i);
   if ( i == 5 )
   {
      break;  // -- 5 iteration is enough --
   }
}

See also:

Personal tools
Create a book
  • Add wiki page
  • Collections help