Java HashMap example explained below. HashMap is important concept used mostly in day to day real project programming.
HashMap Implements Map Interface.
 
Complete class HashmapClass.java can be found below;
 

package com.basic;

import java.util.HashMap;

public class HashmapClass {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		HashMap map = new HashMap<>();
		map.put("USA", "Washington");
		map.put("India", "Delhi");
		
		System.out.println("Capital city for India is:"+map.get("India"));
		System.out.println("Capital city for Nepal is:"+map.get("Nepal"));
	}
}

 
Refer YouTube tutorial with detailed explanation
 

 
For official Java Docs refer https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
 
For further reading refer Java Programming Category posts.

Share this post

Learning Java HashMap example
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *