I looked through the database of obsolete codes and observed that so many places they use the class public staticinside the outer class, and the nested open static class is not just used in the outer class, but is used in many other class?
What will be the constructive solution for this and if it will be used outside, and then why it was not created as an independent public class in the first place.
So, in my example, it looks like this: -
public class OuterNestedClass {
private int a;
private List<InnerClass> innerClasses;
public static class InnerClass {
private int b;
public InnerClass(int b) {
this.b = b;
}
public void show(){
System.out.println("Value of b "+b);
}
}
}
And another class that uses innerclassis as follows: -
public class OutsideClass {
public static void main(String[] args) {
OuterNestedClass.InnerClass innerClass = new OuterNestedClass.InnerClass(10);
innerClass.show();
}
}
Let me know if any clarification is required.