This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to link Hashmap and Arraylist

 
Ayan Biswas
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to create a link between hashmap and arraylists such that with every hashmap entry there will be an arraylist linked to it.How can I do it?
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12021
25
Chrome Java Linux
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well...this is just my opinion, but I'd say you need to re-think your design.

Maintaining data in two parallel data structures is almost always the wrong way to do it.
 
Ayan Biswas
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@fred rosenberger actually I need to create an indexing system where I need to read terms from a collection of files and store the word ,frequencies and the list of files(file ids).So, what I thought about storing the word,frequency in the hashmap and the file-ids in the arraylist where the words appear.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't claim to understand precisely what data you are working with here, but what you most likely need to do is define a class to hold all the information associated with a key, and then put the data into instances of that class and store them in the map as the values. Your class might (for example) contain an ArrayList as a member.
 
Ayan Biswas
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Ernest Friedman-Hill thanks..got it..
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic