Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics & collections question  RSS feed

 
Thierry Henry
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
Sheriff
Posts: 15985
86
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!