eclipse错误,“无法打开源级低于1.7”的String类型的值。 [英] eclipse error, "Cannot switch on a value of type String for source level below 1.7"

查看:293
本文介绍了eclipse错误,“无法打开源级低于1.7”的String类型的值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


线程main中的异常java.lang.Error:未解决的编译问题:源代码级别低于1.7时,不能打开String类型的值。


我将Java编译器从1.6更改为1.8 ,但我还是有这个错误。
代码如下:

 包学习; 

import java.util.Scanner;

public class Switch {
public static void main(String [] args){
扫描仪输入=新的扫描仪(System.in);
System.out.println(插入命令:);
String text = input.nextLine();

switch(text){
casestart:
System.out.println(Game Started);
casestop:
System.out.println(Game Stopped);
default:
System.out.println(Invalid Input);
}
input.close();
}
}

我刚刚下载了最新的eclipse和Java SED套件8昨天。可以帮助我吗?

解决方案

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


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.

I changed the Java Compiler from 1.6 to 1.8, but I still have this error. 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. Can anyone help me?

解决方案

Go in project properties->Java Compiler ... Change compliance level to 1.8

这篇关于eclipse错误,“无法打开源级低于1.7”的String类型的值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆