Suppose the following Java code,
public class ParentClass{
private parentClass(){}
public class ChildClass {
public ChildClass(){}
}
}
I cannot instantiate the ChildClass
like this:
new ParentClass.ChildClass();
This is only possible by making the ChildClass
static
in Java, whereas it can be done in C# without making it static.
My question is that if the nested class is static then why it can be instantiated in Java and why the same is not possibe in C#. Is the definition of static different for the two languages?
I have seen this stack post, but it does not answer my question.