Saturday, December 11, 2010

What does the break statment do???

break statment is usually used to stop the loop execution immediately with our letting it to complete its total iterations. It is usually used for infinite loops to search for a specific condition.
for example
public class Demo
{
public static void Main(String[] args)
{
int i=0;
while(1){
i++;
if(i= =10)
{
break;                    //will jump outside the loop when i equals 10
}
}
}
}

No comments:

Post a Comment