public class Parent {
public enum ChildType {
FIRST_CHILD("I am the first."),
SECOND_CHILD("I am the second.");
private String myChildStatement;
ChildType(String myChildStatement) {
this.myChildStatement = myChildStatement;
}
public String getMyChildStatement() {
return this.myChildStatement;
}
}
public static void main(String[] args) {
// Why does this work?
System.out.println(Parent.ChildType.FIRST_CHILD.myChildStatement);
}
}
Существуют ли какие-либо дополнительные правила в отношении контроля доступа для родительских подклассов, классов в одном пакете и т. Д. Применительно к этому перечислению? Где я могу найти эти правила в спецификации?