Example usage for java.util HashMap HashMap

List of usage examples for java.util HashMap HashMap

Introduction

In this page you can find the example usage for java.util HashMap HashMap.

Prototype

public HashMap() 

Source Link

Document

Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75).

Usage

From source file:MainClass.java

public static void main(String[] a) {

    HashMap map = new HashMap();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");

    HashMap map2 = (HashMap) map.clone();
    System.out.println(map2);/*from   w  w w  . j  a  v  a 2 s.  com*/
}

From source file:Main.java

public static void main(String[] args) {
    HashMap<String, int[]> h = new HashMap<String, int[]>();
    h.put("PID", new int[] { 1, 2 });

    System.out.println(h.get("PID")[0]);
    System.out.println(h.get("PID")[1]);
}

From source file:Main.java

public static void main(String[] a) {
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");

    HashMap map2 = (HashMap) map.clone();
    System.out.println(map2);//from  ww  w .j a  va  2s.  c  om
}

From source file:Main.java

public static void main(String[] args) {
    HashMap<String, String> hMap = new HashMap<String, String>();

    hMap.put("1", "One");
    hMap.put("2", "Two");
    hMap.put("3", "Three");

    System.out.println(hMap.containsValue("Two"));
}

From source file:Main.java

public static void main(String[] args) {
    HashMap<String, String> hMap = new HashMap<String, String>();

    hMap.put("1", "One");
    hMap.put("2", "Two");
    hMap.put("3", "Three");

    Object obj = hMap.remove("2");
    System.out.println(obj + " Removed from HashMap");
}

From source file:Main.java

public static void main(String[] args) {
    HashMap<String, String> hMap = new HashMap<String, String>();

    hMap.put("1", "One");
    hMap.put("2", "Two");
    hMap.put("3", "Three");

    hMap.clear();/*from  w  w w  . j av  a  2 s  .  c  o  m*/
    System.out.println(hMap.size());
}

From source file:MainClass.java

public static void main(String[] a) {
    Map map = new HashMap();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");

    System.out.println(map);//  www . ja v  a 2s .  co  m
}

From source file:BoxingGenericsExample.java

public static void main(String args[]) {
    HashMap<String, Integer> hm = new HashMap<String, Integer>();

    hm.put("speed", 20);
}

From source file:Main.java

public static void main(String[] args) {
    HashMap<String, String> hMap = new HashMap<String, String>();

    hMap.put("1", "One");
    hMap.put("2", "Two");
    hMap.put("3", "Three");

    boolean blnExists = hMap.containsKey("3");
    System.out.println("3 exists in HashMap ? : " + blnExists);
}

From source file:MainClass.java

public static void main(String[] a) {
    Map map = new HashMap();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");
    map.clear();/*  ww w .  jav  a  2 s  .  c o  m*/

    System.out.println(map);
}