case switch in java strings code example
Example: switch statement in java
public class SwitchStatementExample
{
public static void main(String[] args)
{
char grade = 'A';
switch(grade) {
case 'A' :
System.out.println("Distinction.");
break;
case 'B' :
case 'C' :
System.out.println("First class.");
break;
case 'D' :
System.out.println("You have passed.");
case 'F' :
System.out.println("Fail. Try again.");
break;
default :
System.out.println("Invalid grade");
}
System.out.println("Grade is: " + grade);
}
}