# break Java Keyword

The break keyword is used to prematurely exit a for, while, or do loop or to mark the end of a case block in a switch statement.

## Examples

      for (i=0; i<max; i++)
      {
         if (<loop finished early>)
         {
            break;
         }
      }

      int type = <some value>;
      switch (type)
      {
         case 1:
    	   <statement>
    	   break;
         case 2:
    	   <statement>
    	   break;
         default:
    	   <statement>
      }

## Remarks

- break always exits the innermost enclosing while, for, do or switch statement.

Related Topics

continue Java Keyword

do Java Keyword

for Java Keyword

switch Java Keyword

while Java Keyword