public class SwitchExampleString
{
public static void main(String args[])
{
String choice;
switch(args)
{
case "day1" :
choice="Sunday";
System.out.println(choice);
break;
case "day2" :
choice="Monday";
System.out.println(choice);
break;
case "day3" :
choice="Tuesday";
System.out.println(choice);
break;
case "day4" :
choice="Wednesday";
System.out.println(choice);
break;
case "day5" :
choice="Thursday";
System.out.println(choice);
break;
case "day6" :
choice="Friday";
System.out.println(choice);
break;
case "day7" :
choice="Saturday";
System.out.println(choice);
break;
default :
System.out.println("Wrong choice");
}
}
}
谁能帮助我,我想知道如何在 switch() 中使用字符串。上面显示的是我到目前为止所做的程序。但它显示错误。我安装的java版本是jdk6。