rin_r
asked on
Dual key
I need some HashMap or any other Collection which I can create and search using a dual key.
Each Object can be used as a key, so also instances of your own class (that contains e.g. a String and an Integer)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you want your data keyed on two seperate keys then use two maps.
if you want to combine them you can really do it however you want as long as you implement equals() and hashcode() according to their contracts in the javadoc
if you want to combine them you can really do it however you want as long as you implement equals() and hashcode() according to their contracts in the javadoc
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your map will look like
PrimaryMap
key : 1 value : secondaryMap
key : a value : object with key 1 and a
key : b value : object with key 1 and b
key : 2 value : secondaryMap
key : a value : object with key 2 and a
key : 3 value : secondaryMap
key : c value : object with key 3 and c
key : a value : object with key 3 and a
PrimaryMap
key : 1 value : secondaryMap
key : a value : object with key 1 and a
key : b value : object with key 1 and b
key : 2 value : secondaryMap
key : a value : object with key 2 and a
key : 3 value : secondaryMap
key : c value : object with key 3 and c
key : a value : object with key 3 and a
ASKER
Thank You all
thanx 4 axxepting
Do you mean e.g. two String's? Or a String and an Integer?