Switch
public class SwitchDemo {
public static void main(String[] args) {
int a = 2;
switch (a) {
case 1:
System.out.println"Value of a is 1");
break;
case 2:
System.out.println("Value of a is 2");
break;
case 3:
System.out.println"Value of a is 3");
break;
}
}
}
Output:
Value of a is 2