Normal Class (Non-nested Class) can only is public, abstract or final. For nested classes, the static is allowed.
Nested classes (private, public, protected), 2 Categories.
1. Static Nested Class (Very Different from C # Static Class)
Alpha:have access to all the static members of its parent class.
Beta:can instantiate objects by New Parentclass.staticnestclass (). Now allowed to create objects in C #.
Gamma:can has non-static members.
Delta:same as Gamma. Cannot access parentclass.this.
2. Non-static Nested Class (Inner Class)
Alpha:have access to all the members of their parent class.
Beta:can instantiate objects by New ParentClass (). New Innerclass ().
Gamma:cannot has the static members, the except for final static fields.
Delta:variable Shadowing:
ParentClass.this.memberName, Parent class member.
This.membername, ParentClass.InnerClass.this.memberName-Inner class member
======================================
1. Interface can only is defined inside a top-level class, an Interface or in static context because interfaces is inhere ntly Static.
2. Anonymous Classes:
Interface/abstractclass obj = new Interface/abstractclass (Empty for Interface. Initialize for abstract class) {
String/int ...;
public void Implementabstractmethoda () {...}
public void Implementabstractmethodb () {...}
}; <--semicolon in the end
Java Nested Class