What Is The Advantages Of Inner Classes In JAVA?


2 Answers

Florio Potter Profile
Florio Potter answered

There are many advantages, though some of them are really personal or design preference.
1 - with inner classes you can access private members of the enclosing class.
2 - they are useful for interface implementations that are only used by the enclosing class (event handlers in a application)
3 - they are useful for providing fine grained access and creation control over an interface implementation that is retrieved externally (maybe something like an Iterator implementation)

For more information get help at CodeAvail- Online Computer Science Assignment

Arvind Sharma Profile
Arvind Sharma answered
One advantage of using Java Inner Class is that they can be hidden from other classes in the same package.

Answer Question