Java Map

Map .

  • Map
  • NoSuchElementException
  • Map ClassCastException
  • Null Map Null NullPointerException
  • Map UnsupportedOperationException
1 void clear( )
 
2 boolean containsKey(Object k)
 true
3 boolean containsValue(Object v)
 true
4 Set entrySet( )
 Set
5 boolean equals(Object obj)
6 Object get(Object k)
 null
7 int hashCode( )
8 boolean isEmpty( )
- true
9 Set keySet( )
 Set
10 Object put(Object k, Object v)
11 void putAll(Map m)
12 Object remove(Object k)
13 int size( )
-
14 Collection values( )
Collection

Map

import java.util.*;

public class CollectionsDemo {

   public static void main(String[] args) {
      Map m1 = new HashMap(); 
      m1.put("Zara", "8");
      m1.put("Mahnaz", "31");
      m1.put("Ayan", "12");
      m1.put("Daisy", "14");
      System.out.println();
      System.out.println(" Map Elements");
      System.out.print("\t" + m1);
   }
}

Map Elements
        {Mahnaz=31, Ayan=12, Daisy=14, Zara=8}