❮ Previous Next ❯

Java HashMap

New Picture.png
  1. HashMap is an in-built class which inherits AbstractMap class and implements Map interface.
  2. HashMap maintains key and value pairs and often denoted as HashMap or HashMap.
  3. A HashMap contains values based on the key.
  4. It contains only unique elements.
  5. It may have one null key and multiple null values.
  6. It maintains no order, that means it is not an ordered collection which means it does not return the keys and values in the same order in which they have been inserted into the HashMap.

HashMap class declaration

Let's see the declaration for java.util.HashMap class. public class HashMap extends AbstractMap implements Map, Cloneable, Serializable here, in this declaration :

  1. K: It is the type of keys maintained by this map.
  2. V: It is the type of mapped values.

JAVA HashMap Example:


import  java.util.*;  
class HashMapDemo{  
 public static void main(String args[]){  
  HashMap<Integer,String> hm=new HashMap<Integer,String>();  
  for(Map.Entry m:hm.entrySet()){  
   System.out.println(m.getKey()+" "+m.getValue());  


❮ Previous Next ❯


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved