posted 22 years ago
Shall we come to a conclusion like this for inner class?
Anonymous Inner Class
1) Anonymous inner class is allowed to extend AT MOST one class or to implement AT MOST one interface explicitly.
2) Anonymous inner class always assumed to extend Object if it is not extending any other class or any other interface explicitly.
3) If Anonymous inner class extends a class, then it is not possible to extend anyother class including Object or implement an interface explicitly. But of course, the extended class must be derived from Object.
4) If Anonymous inner class implements a interface, then it is not possible to extend anyother class including Object or implement an interface explicitly. But of course, the extended interface must be derived from Object.
5) Anonymous inner class is one type of Local Inner class.
6) It can call superclass constructor. But how?
Local Inner Class
1) It has only access to the final variables of the enclosing method or final paramer passed to the method.
2) It can extend any number of classes or implement any number of interfaces.(Not sure)
3) Can not be decared with any modifier(only default is allowed)
4) static is not allowed
5) Can be declared inside a block like { /*Inner Class */} But why?
Member Inner class
1) All modifiers are allowed including private and protected.
2) static class is possible
3) Has access to enclosing class including private.
Correct me guys, if anything wrong in this and add more points to this to get a basic understanding of the Inner Classes.
Thanks,<br />Thiru<br />[SCJP,SCWCD,SCBCD]