what is difference betwwen hashmap and hashtable ?
Answers were Sorted based on User's Feedback
Answer / deep pratap singh
HashMap HashTable
1> Not Synchronized Synchronized
2> can contain null cann't
You may also make HashMap Synchronized using generic
methods. Using Hashtable is bad habit. Try to avoid it.
Is This Answer Correct ? | 10 Yes | 2 No |
Answer / ravikiran
hashmap allows one null key and multiple null values.
hashtable doesn't allow null elements
hashmap is not synchronized
hashtable is snchronized
hashmap is not legacy
hashtable is legacy
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / ajay yadav
Hash Map allows null values.
Hash Table dont allows null values.
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / javablossom
The Iterator is used in the hashmap is fail-safe and
whereas the Enumerator used in hashtable is not fail-safe.
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sekhar
Both class are under map interface.But hash table is
synchronized.hashMap is not.we can explictly synchronize
hash map by using the method
Collections.synchronizedMap(Hash Map);
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / kvn
Hash map contains null values,but hash table does not.
Is This Answer Correct ? | 1 Yes | 3 No |
What is OOPS Concept?
Explain JSP life cycle
What class allows you to read objects directly from a stream?
What are the types of classes in java?
What are inner and anonymous class?
what is the difference between HashMap and Hashtable
17 Answers Value Labs, Virtusa,
public class Test { public static void main(String ar[]) { Integer a = 10; Integer b =10; Integer c = 145; Integer d = 145; System.out.println(a==b); System.out.println(c==d); } }
What is the difference between method and means?
What is the maximum size of a string in java?
Java does not support multiple inheritance. how interface helps in the same?
Why does java have two ways to create child threads?
Explain oops concepts in detail?