switch case on string java code example
Example: Java switch case with string
// Java switch case with string
public class SwitchCaseWithString
{
public static void main(String[] args)
{
String str = "twelve";
switch(str)
{
case "ten":
System.out.println("ten");
break;
case "eleven":
System.out.println("eleven");
break;
case "twelve":
System.out.println("twelve");
break;
default:
System.out.println("doesn't match");
}
}
}