"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Oracle certified JPA Developer (1Z0-898),Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist
"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Oracle certified JPA Developer (1Z0-898),Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist
What is the real reason for including inner class as a feature in Java?
[List of FAQs] | [Android FAQ] | [Samuh Varta]
2. They can inherit from a class different from the one that an outer class inherits from. So effectively we have a class inheriting from two classes, normally not available in Java.
What is the real reason for including inner class as a feature in Java?
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Monu Tripathi wrote:I've heard that inner classes are used to implement closures and callbacks. (Objects that maintain the information about their state and context and can be used from other code blocks)
Also, Nested Inner Class in an interface can be used to provide default implementation for the interface(I know you are not talking about Nested Inner Classes but I thought I'd share either ways).
"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Ankit Garg wrote:An inner class doesn't have an IS-A relation with the outer class unless you specify it.
Ankit Garg wrote:Abhay gave a good example of the use of inner classes.
"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Inner Class and Nested Inner Class are the same thing
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I don't know much(anything!) about closures & callbacks, I'll see if I can find more about it.
[List of FAQs] | [Android FAQ] | [Samuh Varta]
Monu Tripathi wrote:I think the book, Thinking in Java has a section called Why Inner classes?, in a related chapter
"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
SCJP 6
Consider Paul's rocket mass heater. |