Monday, 16 March 2015

LinkedHashMapDemo Java program

import java.util.*;
import java.util.Map.Entry;

public class LinkedHashMapDemo {

public static void main (String args[]){

LinkedHashMap lhm = new LinkedHashMap();

lhm.put("kapil", new Double(100.5) );
lhm.put("gaurav", new Double(200.6));
lhm.put("any", new Double(10.5));

Set> ss = lhm.entrySet();
Iterator> i =ss.iterator();

while(i.hasNext()){
Entry m = (Entry) i.next();
System.out.println("Here is key >> "+ m.getKey() );
System.out.println("Here is value >>"+ m.getValue());

}
System.out.println();
     
      double balance = ((Double)lhm.get("kapil")).doubleValue();
      lhm.put("kapil", new Double(balance + 1000));
      System.out.println("kapil new balance: " +
      lhm.get("kapil"));

}

}

No comments: