What is an 'Inner Class' (or Nested Class), and when is it conceptually appropriate to use one?

Last updated 5 July 2026

  • A nested class is defined inside another class to express tight coupling. A non-static inner class is tied to an outer instance, while a static nested class is just a namespaced helper.

  • Use it when the type only makes sense within its enclosing class (e.g. Node inside LinkedList) or for one-off callbacks. This keeps implementation types hidden.

  • Non-static inner classes hold an implicit reference to the outer object and can leak memory, so prefer static nesting unless the outer instance is needed.

  • https://www.infoworld.com/article/2173826/java-tip-75-use-nested-classes-for-better-organization.html
  • https://www.androidengineers.in/roadmap/kotlin/lesson/nested-and-inner-classes
All Object-Oriented Programming interview questions