This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Generics & collections question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Generics & collections question" Watch "Generics & collections question" New topic

Generics & collections question

Thierry Henry

Joined: Jun 20, 2007
Posts: 1

i'm trying to create a type L that extends a List containing elements of type E.

I can't create an instance in the above example.. Anyone has some pointers or an example of how to go about this?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074

If I'm not mistaken, this is unfortunately not possible, because of the way Java generics currently work (with type erasure).

See this from Angelika Langer's excellent Java Generics FAQ:
Can I create an object whose type is a type parameter?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
I agree. Here's the link:
subject: Generics & collections question
Similar Threads
Help Me Downcast
Generic return type
Generic return types
LinkedList problem