Java ClassesLesson 37Free preview
Java Inner Classes
This lesson is part of Java · All levels
Summary
An inner class is a class that is declared within another class so that the program structure feels more organized. Java knows several forms, from the member inner class, the static nested class, to the local class that is within the method. The inner class is most useful when a type only makes sense as part of its outer class.
Key points
- Members of the inner class are written directly within the outer class body.
- Static nested class can be created without the object of the class outside.
- Local class is declared within the method and only applies within the scope of that method
- Inner class easily accesses the field and method belonging to the outer class
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.