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!

Why is the extends constraint necessary?

843793Sep 26 2002 — edited Sep 26 2002
I'm sure there is a good reason, but why is the extends constraint necessary in the generics spec? For example:
public class Foo <E extends Bar>
instead of
public class Foo <Bar>
It seems to me that proper design would usually dictate that Bar be an abstract class or interface in this instance anyway, so the extends constraint should be implicit. I am new to Java generics but have some experience with templates in C++. What am I missing here?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 24 2002
Added on Sep 26 2002
1 comment
98 views