How can i implements a class like an HashMap but with 2 keys ?




Hi all,
i am a newbie, i want to create a class that works like an HashMap but
with 2 keys, get(key1,key2) -> value

I was thinking to create a class "Pair" that override equals and hashcode
and then store here the two keys and then a class that holds an HashMap
with Pair as key and the value class, can be this a solution? or what can
i use?

Bye thanks for the help
.



Relevant Pages

  • Re: JSTL displaying relational data on a JSP
    ... The solution to my first question was to convert all of the IDs to ... Strings and store the object in the HashMap with a string key. ... > the HashMap correspond to the primary keys for each company. ...
    (comp.lang.java.programmer)
  • Re: Weak/Soft references?
    ... | I read this "canonicalizing HashMap" from WeakReference's javadoc. ... so show me all your keys ... ... If you wanted to rely on iteration ... Hendrik Maryns ...
    (comp.lang.java.programmer)
  • Re: HashMap cloning?
    ... Now it seems to me that if you do not clone the keys or the values ... contained in the HashMap, what you are left with is an EMPTY HashMap, ... which case I might as well just have a second reference to the ...
    (comp.lang.java.programmer)
  • Re: Beginner Java Help
    ... > iterate through all of the counts and extract the max. So you'll have to ... The Map interface (which HashMap implements) has methods entrySet(), ... the keys and the values respectively. ...
    (comp.lang.java.help)
  • Re: hash two keys to one index
    ... Well, if I want to pull up all the data pertaining to a student, but I ... That is a very good reason for having a HashMap with names as keys, ... a HashMap with student numbers as keys... ... It might be slightly slower than two tables, ...
    (comp.lang.java.programmer)