- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Displaying content of a HashMap in Java
Let us first create a HashMap and add elements −
HashMap hm = new HashMap(); hm.put("Wallet", new Integer(700)); hm.put("Belt", new Integer(600));
To display the content, just print the HashMap object −
System.out.println("Map = "+hm);
The following is an example to display content of a HashMap −
Example
import java.util.*; public class Demo { public static void main(String args[]) { // Create hash map HashMap hm = new HashMap(); hm.put("Wallet", new Integer(700)); hm.put("Belt", new Integer(600)); System.out.println("Map = "+hm); } }
Output
Map = {Belt=600, Wallet=700}
- Related Articles
- Create a HashMap in Java
- HashMap in Java
- Find the size of a HashMap in Java
- Traverse through a HashMap in Java
- Internal Working of HashMap in Java
- Clone HashMap in Java
- Initialize HashMap in Java
- Retrieve a set of Map.Entry elements from a HashMap in Java
- Display HashMap elements in Java
- Hashmap vs WeakHashMap in Java
- Displaying at most 10 characters in a string in Java
- Sorting a HashMap according to keys in Java
- Sorting a HashMap according to values in Java
- Check if a HashMap is empty in Java
- Iterate through the values of HashMap in Java

Advertisements