Closed zhengye1 closed 6 years ago
I was trying to create a tricky question, it doesn't have a special meaning.
I mean, an Enum can have fields, methods and constructors, and of course, you can use the new operator to instantiate the fields or other objects inside methods/constructors:
public enum MyEnum {
ONE(1), TWO(2);
private BigDecimal asBigDecimal;
private List<String> list = new ArrayList<String>();
MyEnum(int i) {
asBigDecimal = new BigDecimal(i);
}
}
Thank you ~
one of the explanation for the question is following:
I get the second half of the statement, which means we cannot do this
But what is means
and can you provide me an example for this?