A HashMap of HashMaps

Question:
I have been looking everywhere for information on HashMaps,particularly how to put one hash map into another HashMap.

Answer:
This is where the expression RTFM (Read That Fine Manual) comes tomind. Although notorious for being extremely sparse in certainsections, the javadoc API documentation that comes with the Java 2Platform SDKs is extremely helpful in describing the use of theHashMap class. I cannot overstate how useful it is to have a Webbrowser opened to the API docs at all times when writing Javaprograms.

In short, HashMap is a reimplementation of the Hashtable class to workwith the Java 2 Collections Framework. Unlike Hashtable, none of itsmethods are synchronized. A HashMap associates a value with anarbitrary key. These associations are created with theput(Object key, Object value) method. An association canbe removed with remove(Object key). Any object can be stored as a value , including a HashMap. To store one HashMap intoanother, simply use it as the value argument to put().

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: