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

Hi,

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

Thanks

View Answers

April 16, 2013 at 3:53 PM

Hi friend,

Java facilitate to write a class within another class called Nested class. Nested class is of two types static and non-static. Static nested class is a class which is declared using 'static' keyword and the non-static classes are called inner/non-static nested class.

Non-static nested class have full access of all the members inside which it is nested whereas, static nested class can't invoke non-static methods or access non-static fields of an instance of the class within which it is nested.

For more detail please go through the following link

http://www.roseindia.net/java/master-java/Static.shtml

http://www.roseindia.net/help/java/n/java-nested-class.shtml

http://www.roseindia.net/java/master-java/inner.shtml









Related Tutorials/Questions & Answers:
Advertisements