我写这个程序练习使用多个程序(我正在使用eclipse)。我无法让switch语句正常工作:
Eclipse一直告诉我,令牌案例存在语法错误,并且有一个断言?
public class MultiClass {
public static void main(String args[]) {
MultiClassTwo MCT = new MultiClassTwo();
MultiClassThree MCTT = new MultiClassThree();
MultiClass4 MCF = new MultiClass4();
int determiner;
determiner = 1;
Switch(determiner) {
case 1:
MCT.simpleMessage();
break;
case 2:
MCTT.simpleMessage();
break;
case 3:
MCF.simpleMessage();
break;
default:
System.out.println("This is the first class.");
}
}
}
以下是其他类的单独文件:
public class MultiClassTwo {
public void simpleMessage() {
System.out.println("This is the second class.");
}
}
public class MultiClassThree {
public void simpleMessage() {
System.out.println("This is the third class.");
}
}
public class MultiClass4 {
public void simpleMessage() {
System.out.println("This is the fourth class.");
}
}
答案 0 :(得分:3)
关键字switch
应以小写的'