开发者

Switch program failure

开发者 https://www.devze.com 2023-01-10 03:31 出处:网络
I wrote this program to practice using multiple programs(i\'m using eclipse). and I can\'t get the switch statement to work properly:

I wrote this program to practice using multiple programs(i'm using eclipse). and I can't get the switch statement to work properly:

Eclipse keeps telling me that there is a syntax error on the token case and an assert is expected?

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;
   defau开发者_如何转开发lt:
    System.out.println("This is the first class.");
  }
 }
}

and here are the seperate files for the other classes:

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.");
 }
}


The keyword switch should start with lower-case 's'

0

精彩评论

暂无评论...
验证码 换一张
取 消