java - How to get the first four values from Hashmap -
here hashmap<integer, string>
storing value, , string
associated value. far know, when put value , string
hashmap
, sort value (because value here integer
) in ascending order.
and now, want values rank1 rank4, if not know value of key, how should that?
no, incorrect:
hashmap, sort value
hashmap not order keys. if want that, ought use treemap. uses natural ordering of keys.
if use linkedhashmap, it'll preserve insertion order you. maybe knowing useful.
you'd spend less time here asking questions better answered spending more time reading javadocs classes implement map
interface. maybe tour through collections tutorial help, too.
Comments
Post a Comment