Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic