posted 15 years ago
Ankit is right. If you want to be overly technical, you could say that all classes can (and indeed must) have constructors. When you don't explicitly declare a constructor, the class obtains the default constructor provided by the compiler. In the case of an anonymous inner class, it is clear why you can't have an explicitly defined constructor, because the constructor must have the same name as the class, but...what's the name of an anonymous class? However, the anonymous inner class must get a default constructor that simply calls the super() constructor of the class extended by the anonymous class (if the anonymous class extends a class.) If the anonymous class instead implements an interface, and given that interfaces do not have constructors, the anonymous class will get a default constructor that doesn't do anything.
All code in my posts, unless a source is explicitly mentioned, is my own.