Statement
break;causes the innermost loop (or switch) that contains it to stop, and causes the program to move to just after that loop or switch. For example, suppose that you have a method isPrime(n) that yields true if integer n is prime and false if not. Then the following method returns the smallest prime number that is greater than n.
public static long nextPrime(long n) { long i; for(i = n+1; ; i++) { if(isPrime(i)) { break; } } return i; }