This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 30th, when you will be able to use this site as normal.

    Forum Stats

  • 3,889,858 Users
  • 2,269,775 Discussions


Why is the extends constraint necessary?

843793 Member Posts: 41,732 Green Ribbon
edited Sep 26, 2002 12:05PM in Generics
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?


This discussion has been closed.