A
Alexis Berry
Hello,
I want to create a HashMap which has a list for each key. Therefore I can store more than one value for each key. (I know this breaks the true use of a hashmap but I want a datastruture that takes one key and hold multiple value)
I thought I would be able to define:
public class MultipleValueHashMap<T, java.util.List<U>> implements Map<T, java.util.List<U>> {
.....
}
I would then construct it by "new MultipleValueHashMap<Inteteger, List<String>()"
Unfortunately this does not compile. I think it might be because I am mixing generic types with real types. Am I correct?
Is there a way I can use a map to store more than one value and use generics?
Thanks
I want to create a HashMap which has a list for each key. Therefore I can store more than one value for each key. (I know this breaks the true use of a hashmap but I want a datastruture that takes one key and hold multiple value)
I thought I would be able to define:
public class MultipleValueHashMap<T, java.util.List<U>> implements Map<T, java.util.List<U>> {
.....
}
I would then construct it by "new MultipleValueHashMap<Inteteger, List<String>()"
Unfortunately this does not compile. I think it might be because I am mixing generic types with real types. Am I correct?
Is there a way I can use a map to store more than one value and use generics?
Thanks