-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathLoops.java
52 lines (42 loc) · 1.43 KB
/
Loops.java
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
45
46
47
48
49
50
51
52
public class Loops {
public static void main(String[] args) {
// 1.
// Can't use incompatible data types in the initialization blocks
// (Syntax error on token "int", delete this token)
// for( long y=0, int x=0; y<6; y++) {
// }
// 2.
// Can't use a comma in the conditional block of for loop
// (Syntax error on token ",", . expected)
// int j=8;
// for( int i = 0; i<6, j>7; i++) {}
// 3.
// while in do-while should have braces
// boolean keepGoing = true;
// int result = 15, meters = 10;
// do{
// meters--;
// if(meters==8) keepGoing = false;
// result -= 2;
// } while keepGoing;
// System.out.println(result);
// 4.
// Normal brak logic
var ostrich = new Character[]{'A', 'B', 'C'};
var ostrich1 = new Character[]{'D', 'E', 'F'};
L1: for( var emu : ostrich ) {
System.out.println("outer " + emu);
L2: for( var emu1: ostrich1 ) {
System.out.println("Inner " + emu1);
break L2;
}
}
// 5.
// bad else and else if
if(true)
System.out.println("hell");
else
System.out.println("hell");
// else if ( false )
}
}