简体   繁体   English

eclipse错误,“无法为低于1.7的源级别打开String类型的值”

[英]eclipse error, “Cannot switch on a value of type String for source level below 1.7”

I am new for eclipse, and could not find the solution for 我是新来的日食,找不到解决方案

Exception in thread "main" java.lang.Error: Unresolved compilation problem: Cannot switch on a value of type String for source level below 1.7. 线程“主”中的异常java.lang.Error:未解决的编译问题:对于低于1.7的源级别,无法打开String类型的值。

I changed the Java Compiler from 1.6 to 1.8, but I still have this error. 我将Java编译器从1.6更改为1.8,但是仍然出现此错误。 The code is as below: 代码如下:

package learning;

import java.util.Scanner;

public class Switch {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Insert a command:");
        String text = input.nextLine();

        switch (text) {
            case "start":
                System.out.println("Game Started");
            case "stop":
                System.out.println("Game Stopped");
            default:
                System.out.println("Invalid Input");
        }
        input.close();
    }
}

I just downloaded the latest eclipse and Java SED kit 8 yesterday. 我昨天刚刚下载了最新的eclipse和Java SED套件8。 Can anyone help me? 谁能帮我?

进入项目属性-> Java编译器...将合规级别更改为1.8

I have java 1.8, the following steps worked for me. 我有Java 1.8,以下步骤对我有用。

1) in eclipse.ini Change java version = 1.7 and launch eclipse, change java compiler settings as 1.7 1)在eclipse.ini中更改Java版本= 1.7并启动eclipse,将Java编译器设置更改为1.7

2) right click on the error, click change compilation settings. 2)右键单击错误,单击更改编译设置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Eclipse的Android项目给出错误:源级别低于1.7时无法打开String类型的值 - Android project using Eclipse gives error: Cannot switch on a value of type String for source level below 1.7 “无法为低于 .. 的源级别打开字符串类型的值” Eclipse 中的错误 - “Cannot switch on a value of type String for source level below ..” error in Eclipse VSC无法为低于1.7的源级别打开String类型的值 - VSC Cannot switch on a value of type String for source level below 1.7 eclipse中的openjdk 1.7:不允许运算符的源级别低于1.7 - openjdk 1.7 in eclipse: operator is not allowed for source level below 1.7 无法将 Java 源级别更改为 Eclipse 中的 1.7 与 Maven - Cannot change Java source level to 1.7 in Eclipse with Maven Java 1.7中的字符串值switch语句抛出错误? - String value in Java 1.7 switch statement throwing an error? 如何修复&#39;&lt;&gt;&#39;运算符不允许源级别低于1.7的1.6? - How to fix '<>' operator is not allowed for source level below 1.7 in 1.6? 对于低于 1.7 的源级别,此处不允许使用资源规范 - Resource specification not allowed here for source level below 1.7 如何解决“对于低于1.7的源级别,此处不允许的资源规范”? - How to fix “Resource specification not allowed here for source level below 1.7”? 低于1.7的源代码级别不允许使用Jboss jsp问题&lt;&gt;运算符 - Jboss jsp issue <> operator is not allowed for source level below 1.7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM