Hello,
I am looking for a collection where I could save 3 keys and data.
Key1_1, Key2_1, Key3_1, data1_1, data2_1, data3_1
Key1_2, Key2_2, Key3_2, data1_2, data2_2, data3_2
Key1_3, Key2_3, Key3_3, data1_3, data2_3, data3_3
Key1_4, Key2_4, Key3_4, data1_4, data2_4, data3_4
Which collection would suit for it or maybe have I take apache commons collection?
Or you can write a simple wrapper around the core HashMap class -- one that uses a class that hold three objects, and calculates a new hashmap and equals based on it. This way, you can use the standard hashmap class.
Step 1: create a MultiKeyMap before the loop.
Step 2: inside the loop, call one of the put methods on the MultiKeyMap you created in step 1.
Step 3: oh wait, there isn't.
MultiKeyMap doesn't support multiple values. That leaves you with a few options:
1) use two separate MultiKeyMaps, with the same keys. The first stores one value, the second the other.
2) store your two values in a container like a String[] or List<String>
3) create a new class for containing the two values.
4) ???