Take a look at the use of both HashMap and HashTable in coding:
HashTable:
Code:
Hashtable<Integer,String> testing = new Hashtable<Integer,String>();
testing.put(1, "Lahore");
testing.put(2, "Karachi");
testing.put(3, null);
System.out.println(testing.get(1));
System.out.println(testing.get(2));
System.out.println(testing.get(3));
HashMap:
Code:
HashMap<Integer,String> testing = new HashMap<Integer,String>();
testing.put(1, "Keys");
testing.put(2, null);
Bookmarks