General discussion

  • Creator
    Topic
  • #2280313

    Nested Class & Inner Class

    Locked

    by itramaraj ·

    What is (are) the difference between Nested class and inner class in Java?

All Comments

  • Author
    Replies
    • #3387369

      Reply To: Nested Class & Inner Class

      by darts32 ·

      In reply to Nested Class & Inner Class

    • #3364551

      Reply To: Nested Class & Inner Class

      by screwmail ·

      In reply to Nested Class & Inner Class

      Nested classes are simply static inner classes. The difference between nested classes and inner classes is the same as the difference between static and nonstatic members of a class: nested classes are associated with the enclosing class itself, whereas inner classes are associated with an object of the enclosing class.

      Because of this, inner class objects require an object of the enclosing class, while nested class objects do not. Nested classes, therefore, behave just like top-level classes, using the enclosing class to provide a package-like organization. In addition, nested classes have access to all members of the enclosing class.

    • #3363485

      Reply To: Nested Class & Inner Class

      by itramaraj ·

      In reply to Nested Class & Inner Class

      This question was closed by the author

Viewing 2 reply threads