Refer to this articleArticle:
Http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html
Differences between Nested-class and inner-class:
Nested classes are divided into two categories: static and non-static. Nested classes that are declared
Static
Are simply calledStatic Nested classes. Non-static Nested classes are called
Inner classes.
In the following example, staticnestedclass is a nested class and innerclass is an internal class.
Class outerclass {... static class staticnestedclass {...} class innerclass {...}}
Both Nested-class and inner-class are member variables of the outer class. Only one is static and the other is non-static.
Therefore, both Nested-class and inner-class can be declared as private, public, protested, or package private (recall here, the general class can only be public or package private when declared ).
But there are differences between static and non-static: Nested-class is related to the class, and inner-class is related to the instance. Therefore, you can directly access the nested-class without instantiating the object, but you must instantiate the class to access the inner-class. Nested-class cannot access other member variables or methods of the outer class, while inner-class can.
Here is another interesting thing: Because inner-class is a non-static member variable, no static variables or methods can be defined in inner-class.