Nested and Inner classes

Nested vs. inner classes in Kotlin and a mnemonic for distinguishing them. An explanation of labels and qualified this expressions, with a brief note on anonymous inner classes

Gabriel Shanahan
The Kotlin Primer

--

— — — — — — — — — — — — — — —

THE CURRENT VERSION OF THIS ARTICLE IS PUBLISHED HERE.

— — — — — — — — — — — — — — —

Tags: #FYI #KOTLIN FEATURE

This article is part of the Kotlin Primer, an opinionated guide to the Kotlin language, which is indented to help facilitate Kotlin adoption inside Java-centric organizations. It was originally written as an organizational learning resource for Etnetera a.s. and I would like to express my sincere gratitude for their support.

It is recommended to read the Introduction before moving on. Check out the Table of Contents for all articles.

Kotlin uses explicit keywords to clear up the confusion between nested classes and inner classes. To recap:

  • A nested class is a static class defined inside another class. It is not bound to a specific instance of the outer class.
  • An inner class is a non-static class…

--

--