inner-classes
7 tutorials tagged “inner-classes”.
- Anonymous Class vs LambdaAnonymous classes and lambdas can both implement an interface inline. Learn the differences in syntax, this, state, interfaces supported and performance.
- Anonymous Inner Class in JavaDeclare and create a one-off class in a single expression: implementing interfaces, extending classes with arguments, the rules, and lambdas.
- Inner Classes in JavaClasses inside classes: the four kinds of nested class, what each can access, how to choose, and the Outer$Inner class files the compiler creates.
- Local Inner Class in JavaA class declared inside a method: scope, capturing effectively final variables, local records, enums and interfaces, and when a local class beats a field.
- Member Inner Class in JavaA non-static class inside a class body: each object is tied to an outer object, reads its private fields, uses Outer.this, and can keep the outer alive.
- Nested Interface in JavaInterfaces declared inside classes or interfaces: why they're implicitly static, how to implement and refer to them, and Map.Entry as the classic example.
- Static Nested Class in JavaA static class inside another class: no outer object needed, how it differs from an inner class, typical uses like builders and Map.Entry, and errors.