Hashmap in Java

Example use of hashmap in java

import java.util.*;

public class HashMapDemo {

  public static void main(String[] args) {

    HashMap hm = new HashMap();
    hm.put(“Susan”new Double(3434.34));
    hm.put(“George”new Double(123.22));
    hm.put(“Jimmy”new Double(1200.34));
    hm.put(“Kim”new Double(99.34));
    hm.put(“Steve”new Double(-19.34));
    Set set = hm.entrySet();

    Iterator i = set.iterator();

    while(i.hasNext()){
      Map.Entry me = (Map.Entry)i.next();
      System.out.println(me.getKey() “ : ” + me.getValue() );
    }

  }
}

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.