I've seen this sample code from Oracle Website about Java ?
public class Parent { class InnerClass { void methodInFirstLevel(int x) { // some code } } public static void main(String... args) { Parent parent = new Parent(); Parent.InnerClass inner = parent.new InnerClass(); } } - What is the purpose of the construct
parent.new InnerClass()? - What kind of classes would be suited to such construction?
The title may be misleading: I understand everything about this construct.
I just don't understand where and when to use this Java feature.
I found another syntax to do the same: Java: Non-static nested classes and instance.super()
There are lot's of references about this structure, but nothing about the application.
[References]
Builderfor the Builder design pattern...