• Post Reply Bookmark Topic Watch Topic
  • New Topic

Collection Decalaration.  RSS feed

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 "?" ?

Regards

Suresh.
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi suresh,

see this link you will get some idea about generic collection

www.ibm.com/developerworks/java/library/j-jtp01255.html


thanks & regards,
seetharaman
 
Ranch Hand
Posts: 95
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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


But,
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!