tag:blogger.com,1999:blog-8563220776994779598.post2621699372341141910..comments2024-03-17T08:20:24.832-07:00Comments on My Tech Learnings: Convert HashMap to HashTableLavnishhttp://www.blogger.com/profile/16714741724993845980noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-8563220776994779598.post-84612510653402617872012-06-05T22:51:18.537-07:002012-06-05T22:51:18.537-07:00PutAll will give you a NPE
public static void...PutAll will give you a NPE<br /><br /> public static void testThree() {<br /> Map map = new HashMap();<br /> Hashtable ht = new Hashtable();<br /> map.put("a",null);<br /> map.put("b","B");<br /> map.put(null,"D");<br /> ht.putAll(map);<br /> System.out.println(ht);<br /> }Lavnishhttps://www.blogger.com/profile/16714741724993845980noreply@blogger.comtag:blogger.com,1999:blog-8563220776994779598.post-47968078948329582972012-02-16T22:14:12.902-08:002012-02-16T22:14:12.902-08:00Nice tip. putAll(map) seems better to me.
Thanks...Nice tip. putAll(map) seems better to me. <br /><br />Thanks<br /><a href="http://javarevisited.blogspot.com/2010/10/difference-between-hashmap-and.html" rel="nofollow">difference between hashtable and hashmap</a>Java Listhttp://javarevisited.blogspot.com/2011/05/example-of-arraylist-in-java-tutorial.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8563220776994779598.post-15674159656084201482009-11-11T07:46:07.313-08:002009-11-11T07:46:07.313-08:00try doing that ...
tell me whats the result u get...try doing that ... <br />tell me whats the result u get ...<br />u r in for a surprise !!Lavnishhttps://www.blogger.com/profile/16714741724993845980noreply@blogger.comtag:blogger.com,1999:blog-8563220776994779598.post-40855530214687971322009-11-11T07:40:12.950-08:002009-11-11T07:40:12.950-08:00You can just instantiate a Hashtabe by passing it ...You can just instantiate a Hashtabe by passing it a Hashmap, thus:<br /><i><br />HashMap map = new HashMap();<br />Hashtable ht = new Hashtable(map);<br /></i>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8563220776994779598.post-58688879998294221002009-02-28T18:01:00.000-08:002009-02-28T18:01:00.000-08:00hi anurag thanks for the infoI will ty this one ou...hi anurag thanks for the info<BR/>I will ty this one out and post it accordinglyLavnishhttps://www.blogger.com/profile/16714741724993845980noreply@blogger.comtag:blogger.com,1999:blog-8563220776994779598.post-2316400060947458482009-02-26T21:36:00.000-08:002009-02-26T21:36:00.000-08:00How about using the putAll(Map) method of a Hashta...How about using the putAll(Map) method of a Hashtable<BR/><BR/>ht.putAll(map);<BR/><BR/>that would work fine :)lazycoderhttps://www.blogger.com/profile/06992489708736953121noreply@blogger.com