This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Java in General and the fly likes Generics Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Generics Question" Watch "Generics Question" New topic

Generics Question

Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536

whats wrong with this? The compiler complains that it cannot instantiate the type ArrayList<? extends someAbstractClass>

MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
You cannot use wildcards in constructor calls. Use

new ArrayList<someAbstractClass>()


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link:
subject: Generics Question
It's not a secret anymore!