Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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 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.

 

 

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