switch(title)
{
case "Return":
returnBooks();
break;
}
Run Code Online (Sandbox Code Playgroud)
-source 1.6中不支持switch中的字符串,使用-source 7或更高版本来启用switch中的字符串
所以,我已经安装了JDK7,为什么编译器显示此消息并在编译时出错?
我正在使用NetBeans
Mat*_*all 15
我讨厌说出来,但是:阅读错误信息.它告诉你究竟是什么问题.
您正在使用Java 6模式进行编译,而不是在Java 7模式下进行编译.如果您正在使用javacJDK 7附带的,如错误消息所示,请使用-source 7标志:
> javac -source 7 {stuff here}
Run Code Online (Sandbox Code Playgroud)
Bot*_* FM 11
用户查询的两个关键点:
因此,netbeans带有两个包:
意味着在安装Netbeans 7时它会自动安装JDK 7并将JDK 7设置为默认库.
在安装NetBeans 7时,它在系统中找到了JDK,如果发现它也会自动配置库的路径,但会显示有关JDK7的路径和版本的信息.
所有用户都试图给出该查询的正确答案,但没有人能够以用户需要的正确方式回答,因为用户也使用Netbeans.
继续使用Hemal Pandya的编辑版本,需要配置一件事,就是这样
RightClick on Project > properties > and in the categories option select > source. see the
**Hemal Pandya** edit version to look at image, the source option is available above the
Libraries option.
Run Code Online (Sandbox Code Playgroud)
和
then select **Source/Binary Format** form bottom and set it to JDK 7 (= 1.7). this is the exact solution
of user's post and I am 100% sure now String in swich will work
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15781 次 |
| 最近记录: |