我遇到了一个非常奇怪的错误,我不知道如何解决。
I came across a very weird error that I just can't figure out how to solve.
一个在Windows上编译的项目不会在Linux上编译出以下错误:
A project, that compiles just fine on Windows, doesn't compile on Linux with the following error:
Cannot switch on a value of type AClass.Bbb. Only convertible int values, strings or enum variables are permitted,即使所陈述的类型是一个枚举。
, even though the stated type is an enum.
类的代码是这样的:
The code of the class is something along these lines:
public class AClass { private enum Bbb { ONE, TWO; } public void aMethod(List<Bbb> arg) { for (Bbb en : arg) { switch (en) { .... } } } }
switch(en)中的 en 下划线,并显示上述错误通知。
The en in switch(en) is underlined, with the error notification stated above.
有其他人有吗?有没有办法解决这个问题?
Has anyone else had it? Is there a way to solve this?
UPD Java版本:
java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)推荐答案
如果您使用JDK1.7 .Try按照以下步骤查看
The problem should go away if u r using JDK1.7 .Try following the below steps and see
如果您在下面执行,则问题重新出现
If u do below , then the problem reappears.
以下是我看到的如果我执行以下操作...
Here's what I see if I do the following...
希望这有帮助!!
更多推荐
Java编译错误:打开枚举
发布评论