class HashMap<M,N>
|
package javaLearnings;
import java.util.*; // Demonstrate LinkedList. public class Main { public static void main(String args[]) { // Create a hash map. HashMap hm = new HashMap(); // Put elements to the map hm.put("Mukul Agrawal", new Double(4737.23)); hm.put("Technical content writter ", new Double(234.545)); hm.put("Web desinging house", new Double(2342.23)); hm.put("Online Promotion House", new Double(33.123)); hm.put("Hello world", new Double(-435.32)); // Get a set of the entries. Set> set = hm.entrySet(); // Display the set. for(Map.Entry me : set) { System.out.print(me.getKey() + ": "); System.out.println(me.getValue()); } System.out.println(); // Deposit 1000 into John Doe's account. double balance = hm.get("Mukul Agrawal"); hm.put("Mukul agrawal", balance + 1000); System.out.println("Mukul agrawals new balance: " + hm.get("Mukul agrawal")); } } |