JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

Showing posts with label Hashtable. Show all posts
Showing posts with label Hashtable. Show all posts

difference and Similarities between Hashtable and HashMap in Java

4:02 AM
Similarities between Hashtable and HashMap in Java 1) Both Hashtable and HashMap implements java.util.Map interface. 2) Hashtable and HashMap both are a hash based collection and works on the principle of hashing. 3) Hashtable and HashMap both provide constant time performance for put and get method if objects are distributed uniformly across bucket. 4) From JDK 4 both Hashtable and HashMap are part of Java collection framework. Difference between Hashtable and HashMap in Java 1) First and most significantly different between Hashtable and HashMap are that HashMap is not thread-safe  while Hashtable is a thread-safe collection. 2) The second important difference between Hashtable and HashMap is performance since HashMap is not synchronized it perform better than Hashtable. 3) The third difference on Hashtable vs HashMap is that Hashtable is obsolete class and you should be using ConcurrentHashMap in place of Hashtable in Java.

.