What is the difference between a static and a non-static inner class?

What is the difference between a static and a non-static inner class?

Like static methods and static members are defined in a class, a class can also be static. To specify the static class, prefix the keyword ‘static’ before the keyword ‘class’.

Example :
public static class InnerClass { … }

Differences between static classes and non-static classes:

A static inner class is like other regular classes. They need to be referred by the class name being it is static, e.g. OuterClass.InnerClass. A static inner class can have access even to the private members of the outer class.

The non-static inner class has the reference that is not visible in the outer class. To utilize the non-static inner class attributes and methods, its instance is to be created in the outer class.
Difference between the String and StringBuffer classes
Difference between the String and StringBuffer classes - String class is immutable. The characters of string objects can not be changed / modified...
What is the Dictionary class?
What is the Dictionary class? - The Dictionary class is an abstract class. The class maps keys to values...
What is the ResourceBundle class?
What is the ResourceBundle class? - A ResourceBundle is a group of related sub classes which are sharing the same base name...
Post your comment
Discussion Board
Wrong phrase about inner static class!
Quote: A static inner class can have access even to the private members of the outer class.
This is wrong, only non-static class can have access to private members!!!
Steve 04-30-2015