Here are some major differences.
Nested classes may not access any enclosing class instance fields or methods unless they have an instance of the enclosing class. Inner classes may access those fields directly.
Depending on the access level, nested static classes may be directly instantiated from outside the enclosing class.
class A {
static class B {
}
}
A.B b = new A.B();
non static inner classes require an instance of the enclosing class before they can be instantiated.
class A {
class B {
}
}
A a = new A();
A.B b = a.new B();
- Static classes are good for grouping and creating inner objects which do not rely on instance fields of the parent class. One could view them as helper classes. Non static inner classes are good for creating listeners, iterators, etc which would probably depend on interacting directly with features of the enclosing class.