How to declare HashMap in HashMap
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi,
I want to declare a HashMap where key is of the type "String" and value is a "HashMap".
Here is what I want to declare,
How do I declare this in Java 5.0?
I want to declare a HashMap where key is of the type "String" and value is a "HashMap".
Here is what I want to declare,
How do I declare this in Java 5.0?
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I think so it will work
There is term "map of maps " which describe this functionality.
Regards
HashMap hm1=new HashMap();
HashMap hm2=new HashMap();
hm2.put("key",hm1);
There is term "map of maps " which describe this functionality.
Regards
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Just the way you have written it. What exactly is your doubt here? 

Cheers!
RSR
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Better to declare the Map as type Map<String, Map<Foo>>.
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The problem in this case can be the length of the overall declaration:
There's not a lot you can do about that though. Either you will have to deal with the length, or lower the constraint in the declaration and cast instead.
There's not a lot you can do about that though. Either you will have to deal with the length, or lower the constraint in the declaration and cast instead.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Sujith Mahesh
Greenhorn
Posts: 6
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks Rob,
I will declare like this
and While accessing the object I will cast it.
I will declare like this
and While accessing the object I will cast it.
| She'll be back. I'm just gonna wait here. With this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |












