我不确定该怎么做。请让我知道我做错了什么以及如何解决它。谢谢。我看过很多帖子和我做的任何事情只会增加问题。再说一次,我现在只编写了几天。
public class TestRun {
public static void main(String[] args) {
char Button = '1';
switch (Button) {
case '1': System.out.prntln(" return ") ;
break;
case '2': System.out.prntln(" enter ") ;
break;
case '3': System.out.prntln(" welcome ") ;
break;
default: System.out.prntln(" hello ") ;
}
}
}
/Users/levi_kline/Desktop/TestRun.java:5: error: cannot find symbol
case '1': System.out.prntln(" return ") ;
^
symbol: method prntln(String)
location: variable out of type PrintStream
/Users/levi_kline/Desktop/TestRun.java:7: error: cannot find symbol
case '2': System.out.Prntln(" enter ") ;
^
symbol: method Prntln(String)
location: variable out of type PrintStream
/Users/levi_kline/Desktop/TestRun.java:9: error: cannot find symbol
case '3': System.out.prntln(" welcome ") ;
^
symbol: method prntln(String)
location: variable out of type PrintStream
/Users/levi_kline/Desktop/TestRun.java:11: error: cannot find symbol
default: System.out.prntln(" hello ") ;
^
symbol: method prntln(String)
location: variable out of type PrintStream
4 errors
[Finished in 1.1s]
答案 0 :(得分:0)
您正在调用不存在的方法。它是println
而非prntln
。
我强烈建议您在IDE中使用内置代码建议或事先阅读javadoc,以便了解正确的名称和参数。