using break to exit a for loop

/*  using break to exit a for loop */


class BreakDemo1
{
    public static void main(String args[])
    {
        for(int i =0;i<100;i++)
        {
            if(i==10) break;      //terminate loop if i is 10
            System.out.println("i ="+i);
        }
        System.out.println("End of Loop");
    }
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|