• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics Question

 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

whats wrong with this? The compiler complains that it cannot instantiate the type ArrayList<? extends someAbstractClass>
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot use wildcards in constructor calls. Use

new ArrayList<someAbstractClass>()

instead.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!