【发布时间】:2017-04-21 12:45:52
【问题描述】:
我在 Eclipse 上运行以下代码,没有任何错误。当我尝试在我的 Ipad 上对 Pico 编译器应用程序执行相同操作时,我得到 4 种类型的错误。附上打印屏幕。知道为什么不能以相同的方式运行吗?
代码:
"'''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''
import java.util.Scanner;
public class switchClass {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter a command: ");
String text = scanner.nextLine();
scanner.close();
switch(text) {
case "start":
System.out.println("Machine started");
break;
case "stop":
System.out.println("Machine stopped");
break;
default:
System.out.println("Command not recognized!");
}
}
}
'''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''
Pico Compiler for Ipad 运行代码:
Pico 编译器错误:
【问题讨论】:
-
据我所知,切换
Strings 是在 Java 7 中引入的。也许您的 Pico 编译器版本不(完全)支持 Java 7?