Static nested class vs. a non-static one A static nested class can not directly access non-static methods or fields of an instance of its enclosing class. They can be accessed by creating the object of the nested inner class. Where as non-static nested class can access to the methods or fields of its enclosing class without creating their instance.
The object creation of a static nested class must be qualified with its inner class. Where as non-static inner class object will be created with its name alone.
Static inner class instance occupies less memory space. Where as the object of non-static inner class occupies more space than static inner class.
|