-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathE_Switch.java
More file actions
34 lines (34 loc) · 1.3 KB
/
E_Switch.java
File metadata and controls
34 lines (34 loc) · 1.3 KB
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
public class E_Switch {
public static void main(String[] args) {
int day = 3;
switch (day) {
case 1:
System.out.println("Monday");
break;
/*
* The break and continue statements change the loop's execution flow, also used
* in switch The break statement terminates the loop and transfers execution to
* the statement immediately following the loop.
*/
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
default:
System.out.println("Could Be any Day"); // No break is needed in the default case, as it is always the
// last statement in the switch.
}
}
}
/**
* for (initialization; condition; increment/decrement) { statement(s) }
* Initialization: Expression executes only once during the beginning of loop
* Condition: Is evaluated each time the loop iterates. The loop executes the
* statement repeatedly, until this condition returns false.
* Increment/Decrement: Executes after each iteration of the loop.
*/
/**
* do { System.out.println(x); x++; } while(x < 5);
*/