File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Collection Decalaration. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Collection Decalaration." Watch "Collection Decalaration." New topic

Collection Decalaration.

Suresh Rajadurai
Ranch Hand

Joined: Feb 22, 2007
Posts: 58
Hi Gurus,

Could you please explain me the following declaration. Collection is very complicated for me.

Map<Object, ? super ArrayList> m = new LinkedHashMap<Object, ArrayList>()
What is the meaning of "?" ?


Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

hi suresh,

see this link you will get some idea about generic collection

thanks & regards,
Andre Brito
Ranch Hand

Joined: Dec 13, 2007
Posts: 95

The key is an Object and the

tries to polimorph it. The content can be all the subclasses of ArrayList.

I'm not very good in Generics too, but I guess is that.
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

The key is an Object

Yes that is true. The key for that Map object is of type Object.

tries to polimorph it. The content can be all the subclasses of ArrayList.

Unfortunately that explanation corresponds to following

means that it can accept the value object as any ArrayList with a generic type that is of type ArrayList, or a supertype of ArrayList. Nothing lower in the inheritance tree can come in, but anything higher than ArrayList is OK.
I agree. Here's the link:
subject: Collection Decalaration.
It's not a secret anymore!