Can a Hash Map have a Key consisting of 2 values?

No there are some restrictions regarding that, and also it will effect the whole structure. I guess I can use SQL queries itself to get the unique values and the copies can be stored in a different hash map. – JavaBits Nov 3 at 13:36 yes but this should be the ideal solution and I should have looked into this before the coding began.

Thanks – JavaBits Nov 3 at 13:37.

Two options: create a wrapper object that contains all values as fields, set them, and then map. Put(id, rowObject) use Multimap (guava).

1 (Or use Map> which is the concept behind Multimap) – david Nov 3 at 11:13 yes, true. But it would require a bit more handling, like instantiating the list. – Bozho Nov 3 at 11:14.

You could use a HashMap where the key is still A10 but now the value is a List. So you could have multiple values for the same key. You only have to pay attention in the insertion that new List is created when the first element is inserted.

May be something like (in pseudocode): HashMap myMap = new HashMap; for (elements to insert){ if (!myMap. ContainsKey(element.key())) ArrayList myList = new ArrayList(); myList. Add(element); myMap.

Put(element.key(), myList); }else{ ArrayList myList = myMap. Get(element.key()); myList. Add(element); myMap.

Put(element.key(), myList); } }.

If you mean that a Key x should map to a list vals (which are the values that x represents), then that is easily doable like this (didnt check the syntax, so don't expect it to compile): //assuming that the keys are of type int and values are of type String Map> myMap = new HashMap().

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions