我有一个私有的枚举,不能暴露在课堂之外。无论如何我可以进行该类型的静态导入,这样我就不必每次都输入枚举类型?或者有没有更好的方法来写这个?例子:
package kip.test;
import static kip.test.Test.MyEnum.*; //compile error
public class Test
{
private static enum MyEnum { DOG, CAT }
public static void main (String [] args)
{
MyEnum dog = MyEnum.DOG; //this works but I don't want to type "MyEnum"
MyEnum cat = CAT; //compile error, but this is what I want to do
}
}