我创建了一个enum:
enum Types { hi, hello, bye }
Run Code Online (Sandbox Code Playgroud)
我在每个枚举中添加了一个getter,如下所示:
enum Types {
hi {
String test = "From hi";
public String getString() {
return test;
},
etc.
}
Run Code Online (Sandbox Code Playgroud)
除了我不能调用"Types.hi.getString()".有没有办法做到这一点?谢谢!