Skip to Main Content

Java APIs

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!

stipulate that a parameterised type must implement an interface

843793Sep 25 2007 — edited Sep 27 2007
Hi,

1000 excuses if this has been asked before:

I want to say "abstract class AbstractHolder<Y>" and also say "oh by the way, Y must implement interface Snodgrass"

In other words I want to limit the kind of subelements which are held by the AbstractHolder so that an attempt to establish an AbstractHolder subclass which holds subelements which do not implement Snodgrass results in a compiler error.

Of course you can put in an "instanceof" check in the constructor... but I think generics should enable you to say "abstract class AbstractHolder<Y implements Snodgrass>"... they don't appear to...

Anything to be done?

Thanks - MRodent
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 25 2007
Added on Sep 25 2007
2 comments
107 views