下面的java代码不能在eclipse中编译。我在这里做错了什么?如果该方法只返回int
而不是enum
,则一切正常,因此它基本上设置正常。问题在于引入枚举返回类型。为什么这个枚举类型没有正确解析?
public class myclass {
public enum mytype {
mytype2,
mytype1,
};
public static mytype retmytype() {
return mytype2;
}
}
//in another class
myclass.mytype t = myclass.retmytype(); //ERROR - myclass.mytype cannot be solved
使用'camelCase'男人! –
@LuiggiMendoza内部枚举总是静态的,即使没有指定 – Daniel
@Luiggi门多萨如果一个枚举是一个类的成员,它是隐式静态的 – Mik378