// Demonstration of the use of string cases in a switch statement
public class StringCase {
public static void main( String[ ] args ) {
switch( args[0] ) {
case "Monday":
System.out.print( args[0].compareTo("Monday") );
break;
case "Tuesday":
System.out.print( args[0].contains("day") );
break;
case "Wednesday":
System.out.print( args[0].equals("Wednesday") );
break;
case "Thursday":
System.out.print( args[0].indexOf("day") );
break;
case "Friday":
System.out.print( args[0] == "Friday" );
break;
default:
System.out.print( args[0] != "Sunday" );
}
}
}
|