Breaking and continuing your for loops - Java Language Basics

Java examples for Language Basics:for

Description

Breaking and continuing your for loops

Demo Code

public class Main
{
     public static void main(String[] args)
      {//from   w  w w  . j a v a  2 s.  c om
           for (int number = 2; number <=20; number += 2)
           {
                if (number == 12)
                      break;
                System.out.print(number + " ");
           }
           System.out.println();
      }
}

Related Tutorials