//巢狀型別與外部型別共享一信任關係可互相存取至private權限的成員
class Outer{
static private String outerStr="Outer attrib";
static public void outerFun(){
System.out.println ("outerFun use "+Inner.InnerStr);
}
static class Inner{
static private String InnerStr= "Inner attrib";
static public void InnerFun(){
System.out.println ("innerFun use "+outerStr);
}
}
public static void main(String[] arg)
{
Outer.outerFun();
Outer.Inner.InnerFun();
}
}
沒有留言:
張貼留言