test Hash code With HashMap - Java Collection Framework

Java examples for Collection Framework:HashMap

Description

test Hash code With HashMap

Demo Code

import java.util.HashMap;
import java.util.Map;

public class Main {

  public static void main(String[] args) {
    String k1 = "b2";
    System.out.println(k1.hashCode());
    String k2 = "aQ";
    System.out.println(k2.hashCode());
    Map<String, String> map = new HashMap<String, String>();
    map.put(k1, "v1");
    map.put(k2, "v2");
    System.out.println(map.size());
  }/*w  w w  .  j a v a 2  s.c  o m*/
}

Related Tutorials