Reputation: 2785
What are the name equivalents and main differences between Java and Kotlin nested/inner/local classes?
Upvotes: 5
Views: 804
Reputation: 2785
These are the name equivalents:
| Kotlin | Java |
|-------------------|-------------------------------------------|
| Inner Classes | Non-Static Nested Classes / Inner Classes |
| Nested Classes | Static Nested Classes |
| Local Classes | Local Classes |
| Anonymous Objects | Anonymous Classes |
This is a quick overview of differences:
In Kotlin inner classes to reference the instance of the outer class, we need to use the qualifier this expression.
Some examples can be found over on this tutorial.
Upvotes: 10