Reputation: 1512
Can I add enums inside other enums? For example:
public enum Enum1 {
VALUE1;
}
public enum Enum2 {
Enum1,
VALUE2;
}
Note: I already know that you can do it like this way:
public enum Action
{
FOO,
BAR;
enum MOVE
{
UP,
DOWN,
LEFT,
RIGHT
}
}
Upvotes: 0
Views: 312
Reputation: 60164
public enum Enum1 {
VALUE1;
}
public enum Enum2 {
Enum1, // Enum1 is just constant
VALUE2;
}
It's possible, but Enum1
in Enum2
is just constant (without any dependency with Enum1
enum), however you can use something like this:
public enum Enum1 {
VALUE1;
}
public enum Enum2 {
VALUE1 (Enum1.VALUE1),
VALUE2 (null);
private final Enum1 enum1;
Enum2(com.github.vedenin.services.image.filter.Enum1 enum1) {
this.enum1 = enum1;
}
public Enum1 getEnum1() {
return enum1;
}
}
Upvotes: 1