Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Java Language
Expertise: Beginner
May 5, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

A HashMap of HashMaps

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

This is where the expression RTFM (Read That Fine Manual) comes to mind. Although notorious for being extremely sparse in certain sections, the javadoc API documentation that comes with the Java 2 Platform SDKs is extremely helpful in describing the use of the HashMap class. I cannot overstate how useful it is to have a Web browser opened to the API docs at all times when writing Java programs.

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

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date