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

查看:171
本文介绍了无法在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. 类型枚举不是通用的;它不能用参数参数化

我在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编译器,并将编译器合规级别设置为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天全站免登陆