【发布时间】:2013-02-18 17:29:52
【问题描述】:
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);
}
}
对于父子类、同一包中的类等的访问控制是否有任何附加规则,参考此枚举?我在哪里可以找到规范中的这些规则?
【问题讨论】:
标签: java enums access-control