What is wrong with this instantiation :
Map<String, String, HashMap<String,String>> map = new HashMap<String, String, HashMap<String,String>>();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A
Map<K,V>is a mapping from keys of typeKto values of typeV. There are only 2 type parameters to a map.You attempted to define a map with 3 type parameters; this is not possible, and has nothing to do with the fact that you’re putting a
Mapinside aMap.A
Map<K1,Map<K2,V2>>works just fine.A
Map<X,Y,Z>does not.It’s possible that you need something like
Map< Pair<L,R>, Map<K,V> >. Java does not have genericPair<L,R>type, but see related questions below for solutions.Related questions
On pairs/tuples:
Pair<L,R>in Java?Pair<String, String>stored inHashMapnot retrieving key->value properlyOn nested maps: