Originally posted by Chandra Bairi:
An inner class is a class which is declared inside a class. Isn't it? Normally a class can be declared inside an inner class. Now inside this inner class why can't we declare static members and interfaces. We can do that in a normal class but why not in an inner class. Hope the question is clear.
Because static meant that it belong to the Class, not belong to an Object instance. And the 'correct' way to access static member is by using the Class's name. When you have an anonymous inner class, well..it is anonymous, so you don't have a Class's name to access the static member.
Same goes to Interface.
As you know inner classifier(class/interface) is also referred by their Outer.Inner name. So with regular class you can have innter class/interface which you can access through it's name, but with anonymous inner class you can't. Especially when considering the purpose of Interface is to provide a contractual obligation for other class to implement. So even if you have an interface inside anonymous inner class, you can't implement the interface since you can't refer to it.
[ October 28, 2003: Message edited by: Wirianto Djunaidi ]