1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
/* Java break statement example. This example shows how to use java break statement to terminate the loop. */ public class JavaBreakExample { public static void main(String[] args) { /* * break statement is used to terminate the loop in java. The following example * breaks the loop if the array element is equal to true. * * After break statement is executed, the control goes to the statement * immediately after the loop containing break statement. */ int intArray[] = new int[]{1,2,3,4,5}; System.out.println("Elements less than 3 are : "); for(int i=0; i < intArray.length ; i ++) { if(intArray[i] == 3) break; else System.out.println(intArray[i]); } } } /* Output would be Elements less than 3 are : 1 2 */ |
Very Cool
Very Very Very Cool
its awesome dude….:D
i want 2say that java program is the best programming language sofar and i love it i dream 2be the best programer in my time.
suprb awesme example……..im non IT student so tis a cool tutorial
It wont check the whole array…It should be continue on line 22 instead of break..
helped me a lot thanks!!!
i < intArray.length I am not understand these concept