• Post Reply Bookmark Topic Watch Topic
  • New Topic

ArrayList versus HashMap  RSS feed

 
vijaya bacina
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have to create different sets of lists(arrayLists) from a ArrayList, so i am using addall, containsall like functions in my code to build new lists. But is it worth changing the base List into Hashmap, just because we can get value by Name instead of going thru loop and find the value??
If i change it to Hashmap in order to create Lists again we have to use for loops or Iterators instead of addall. Please let me know some strong points to keep the base list as ArrayList instead of changing it to hashmap..
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you familiar with LinkedHashMap? They have the same (name,value) pairs as HashMaps but with the ability to iterator over the set in the order the items were inserted like Arraylists.

http://java.sun.com/j2se/1.4.2/docs/api/java/util/LinkedHashMap.html
[ June 05, 2006: Message edited by: Scott Selikoff ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!