-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathBreakStatementDemo.java
More file actions
44 lines (34 loc) · 1005 Bytes
/
BreakStatementDemo.java
File metadata and controls
44 lines (34 loc) · 1005 Bytes
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
36
37
38
39
40
41
42
43
44
public class BreakStatementDemo {
public static void main(String[] args) {
for(int i = 0; i < 10; i++) {
if (i == 5) {
break;
}
System.out.println(i);
}
int [] arrayOfInt = { 43, 455, 4376, 343, 6 };
int lookingFor = 455;
boolean isFound = false;
for(int i =0;i<arrayOfInt.length;i++) {
if(arrayOfInt[i] == lookingFor){
isFound = true;
break;
}
}
if(isFound) {
System.out.println("Hurray number is found");
} else {
System.out.println("Oops ! Number is not found");
}
outerForLoop:
for (int i =1; i<5; i++ ) {
innerForLoop:
for (int j =1; j < 3; j++) {
System.out.println(" i = " + i + " and j = " + j);
if(i == 3){
break outerForLoop;
}
}
}
}
}