Jayesh A Lalwani wrote:Why do you need a constructor in your anonymous class anyways? Can't you do your initialization outside your anonymous class?.
Explaining how the question had been originated, I had the following situation:
Class AA had two constructors, a default constructor and one with a
String argument.
Creating an anonymous class, subclass of AA, i wish to call super("Hello!!") within the constructor of the anonymous class, without to pass a parameter to the subclass instantiated.
The code above prints "default". So how to print "Hello!!", Invoking the constructor with arguments ?
The code below prints "Hello!!"
Now, how to do
prints "Hello!!" invoking super("Hello!!")? I would need a constructor in anonymous class.
Thus arose the question raised, and the final conclusion was that this is not possible.