Thursday, June 25, 2009

How to Use Hash Table


Difference between HashMap and Hashtable :

1) HashMap accepts null key, whereas Hashtable doesn't.
2) HashMap is not thread-safe, whereas Hashtable is thread-safe.

Map map = new Hashtable();
map.put("a", new Integer(1));
map.put("b", new Integer(2));
map.put("c", new Integer(3));
//map.put(null, new Integer(1)); // not allowed

0 comments:

 

Sample Java Codes Copyright © 2008 Green Scrapbook Diary Designed by SimplyWP | Made free by Scrapbooking Software | Bloggerized by Ipiet Notez