java - Hash map with multiple keys? -


this question has answer here:

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

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -