Write a program to show the use of switch case statement.
1 year ago
OOP Java
Compile code:
public class Switchstatement {
public static void main(String[] args) {
int number=20;
switch(number){
case 10: System.out.println("10");
break;
case 20: System.out.println("20");
break;
case 30: System.out.println("30");
break;
default:System.out.println("Not in 10, 20 or 30");
}
}
}
Output:
Dipti KC
Jan 8, 2023