Forum Stats

  • 3,852,840 Users
  • 2,264,141 Discussions
  • 7,905,157 Comments

Discussions

Why is the extends constraint necessary?

843793
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?

Comments

This discussion has been closed.