无法在 Eclipse 中编译枚举 [英] Can not compile enums in Eclipse

查看:15
本文介绍了无法在 Eclipse 中编译枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Eclipse 中尝试在我的 Android 项目中引入枚举时,我遇到了以下问题:编译器说:

While trying to introduce enums in my Android project in Eclipse, I encountered with the following problem: Compiler says:

  1. 无法解析 java.lang.Enum 类型.它是从所需的 .class 文件间接引用的
  2. Enum 类型不是通用的;它不能用参数参数化

我在 Ubuntu 10.04 下工作并使用 Eclipse v.3.5.2.尝试同时使用 Java 6 OpenJDK 和 Java 6 Sun,但没有成功.

I work under Ubuntu 10.04 and use Eclipse v.3.5.2. Tried to use both Java 6 OpenJDK and Java 6 Sun, but without success.

有人能帮我解决这个问题吗?

Can anybody help me to sort out with this issue?

代码如下:

public class MyClass {

  public MyClass() {
  }

  ...

  enum MyEnum {
    CONST1, CONST2, CONST3;
  }
}

推荐答案

打开项目的属性,选择Java Compiler"页面,将Compiler Compliance level"设置为1.5"或更高.

Open the properties for the project, select the page "Java Compiler" and set the "Compiler Compliance level" to "1.5" or better.

这篇关于无法在 Eclipse 中编译枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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