Biblioteca Java - Blame information for rev 39

Subversion Repositories:
Rev:
Rev Author Line No. Line
39 mihai 1 package introducere.java.breackcontinue;
4 mihai 2  
3 /**
4  * Exemplify break statement which can be used to terminate a
5  * for, while, or do-while loop.
6  */
7 class BreakDemo {
8     public static void main(String[] args) {
9  
10         int[] arrayOfInts = { 32, 87, 3, 589, 12, 1076,
11                               2000, 8, 622, 127 };
12         int searchfor = 12;
13  
14         int i;
15         boolean foundIt = false;
16  
17         for (i = 0; i < arrayOfInts.length; i++) {
18             if (arrayOfInts[i] == searchfor) {
19                 foundIt = true;
20                 break;
21             }
22         }
23  
24         if (foundIt) {
25             System.out.println("Found " + searchfor
26                                + " at index " + i);
27         } else {
28             System.out.println(searchfor
29                                + " not in the array");
30         }
31     }
32 }