java - Hash map with multiple keys? -
this question has answer here:
- how create hashmap 2 keys (key-pair, value)? 11 answers
can have hash map in java looks this?
hashmap<string, string, integer> hmap = new hashmap<string, string, integer>()
my question similar 1 herequestion
i'm newbie java. want know is, best data structure use if need above, if not valid?
create simple class holding 2 string
objects:
public class mykey { private string a; private string b; // ... accessors, mutators etc. }
and use it's objects keys in map:
hashmap<mykey, integer> hmap = new hashmap<>()
later, add new entry:
hmap.put(new mykey("a", "b"), 2);
Comments
Post a Comment