import java.util.*;

public class HashMapDemo {

  public static void main(String[] args) {

    HashMap hm = new HashMap();
    hm.put("Rohit"new Double(3434.34));
    hm.put("Mohit"new Double(123.22));
    hm.put("Ashish"new Double(1200.34));
    hm.put("Khariwal"new Double(99.34));
    hm.put("Pankaj"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() );
    }

    //deposit into Rohit's Account
    double balance = ((Double)hm.get("Rohit")).doubleValue();
    hm.put("Rohit"new Double(balance + 1000));

    System.out.println("Rohit new balance : " + hm.get("Rohit"));

  }
}
創作者介紹
創作者 kunchung的部落格 的頭像
kunchung

kunchung的部落格

kunchung 發表在 痞客邦 留言(0) 人氣( 19 )