开关案例错误。 Eclipse IDE的在Mac Android开发:更改工作区符合JRE 1.7 [英] Switch Case error. Eclipse IDE for Android development on Mac : Change workspace compliance to JRE 1.7
问题描述
当试图用一个开关箱与开关(字符串)的Android项目,我得到了Eclipse IDE中的错误说:更改工作区符合JRE1.7
When trying to use a Switch Case with switch(string) for an android project , i get an error in eclipse IDE saying: Change workspace compliance to JRE1.7
无法在低于1.7源代码级的一个String类型的值进行切换。只有敞篷INT值或枚举常量允许
Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted
当我更改项目性质为1.7,我得到不同的错误说:
When I change the project properties to 1.7, I get different error saying :
Android的要求编译器遵从性级别5.0或6.0。找到1.7来代替。请使用Android工具>修复项目属性。
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties
我不想改变所有这些配置字符串ENUMS。难道我有什么其他选择?
I dont want to change all those configuration strings to ENUMS. Do I have any other option?
我的环境:
是Eclipse SDK,版本:3.7.2,构建ID:M20120208-0800
操作系统:Mac雪豹(10.6.8)
My environment : Eclipse SDK, Version: 3.7.2, Build id: M20120208-0800 OS : Mac SnowLeopard (10.6.8)
推荐答案
JDK7
不与Android兼容,因此与 JDK6 $ C工作$ C>
JDK7
is not compatible with android so work with JDK6
字符串
在开关
在JDK7被引入,所以它会在给出一个错误JDK6
。你必须使用一个枚举
或 IF-ELSEIF-ELSE
。
String
in switch
was introduced in JDK7, so it will give an error in JDK6
. You have to use either an enum
or if-elseif-else
.
所以,Java编译器切换到 JDK6
。
So, change Java Compiler to JDK6
.
这篇关于开关案例错误。 Eclipse IDE的在Mac Android开发:更改工作区符合JRE 1.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!