Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Without Key can we retrieve particular value in hashmap

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without knowing key can we retrieve particular value in hashmap. Is it possible or not
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the Map.entrySet() and Map.values() methods; those provide access to all values without having to provide a key.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know how to get all values. so no way to retrieve particular value without knowing the key.
 
Lester Burnham
Rancher
Posts: 1337
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What makes a value "particular" if not the key?
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know the value you want, and you can get all values, then you can get all values and iterate until you get the particular value you want.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic