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 make a HashMap index based

 
sakthi moorthy
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI All,

I came across this question in an interview, how do you make a HashMap as index based like ArrayList. for example the way you insert the elements in the HashMap has to be same as the Way you retrieve elements in the HashMap.

The Answer given by me is "always return the same hashCode so that hashCollision occurs and all the elements will be saved in same bucket." still its not maintaing the index. is there any way to make HashMap index based.
 
Don Redd
Ranch Hand
Posts: 82
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as per my knowledge , if you want to maintain insertion order you can use java.util.LinkedHashMap
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic