Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Anonymous classes and non-default constructors

807607Oct 16 2006 — edited Oct 16 2006
I've got a class with only one constructor and that takes an argument. In another class, I want to have an anonymous class that extends this class with something like:

new MyClassWithoutDefaultConstructor(myConstuctorArg) {...}

However, I get a "The constructor MyClassWithoutDefaultConstructor() is undefined".

As a workaround I can create a local class (not anonymous) that extends MyClassWithoutDefaultConstructor and then includes a default constructor which passes my arg to the super constructor. But this is rather messy.

Am I missing something?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 13 2006
Added on Oct 16 2006
3 comments
258 views