• Post Reply Bookmark Topic Watch Topic
  • New Topic

converting generics Hashmap to generics List  RSS feed

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

What is the best way to convert generics HashMap to a generics List.
The HashMap looks like this
HashMap<Integer,CustomClass> customClassColln;

and the List looks like List<CustomClass> customClassList;

Regards,
Mohit
 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean convert?

If you're after the values as it would appear, then HashMap has a method called values(), which returns a Collection.
 
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be careful how you convert the values; a List implies an order, and a Map does not usually maintain an order. But there are linked maps available which record their insertion order.
Look here and look for map implementations.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!