最終更新:2016-09-23 (金) 14:28:21 (2766d)  

ネストされたクラス
Top / ネストされたクラス

Java

メモ

  • Non-static nested classes (inner classes) have access to other members of the enclosing class, even if they are declared private.
  • Static nested classes do not have access to other members of the enclosing class.
  • As a member of the OuterClass?, a nested class can be declared private, public, protected, or package private. (Recall that outer classes can only be declared public or package private.)

種類

staticなネストされたクラス

  • 外部クラスのメンバーにアクセス出来るが、staticなものに限られる。

staticでないネストされたクラス

  • 結び付いている外部インスタンスの非staticメンバーにもアクセス出来る。
  • cannot define any static members itself.

  • OuterClass.StaticNestedClass nestedObject =
         new OuterClass.StaticNestedClass();