difference between HashMap, Hashset and hashTable?

Answers were Sorted based on User's Feedback



difference between HashMap, Hashset and hashTable?..

Answer / sujitpingale

HashMap -
1) unsynchronized and unordered
2) Allow one null key , multiple null values


HashTable -
1) synchronized and unordered
2) Doesn't allow null key and value


HashSet -
1) synchronized and ordered
2) Sort elements in ascending order , doesn't allow duplicate elements

Is This Answer Correct ?    0 Yes 0 No

difference between HashMap, Hashset and hashTable?..

Answer / adarsh m thimmappa

HashTable is a hashing based key-value pair data structure
- doesn't allow null as key
- doesn't allow null as value as well
- not thread safe
- oldest map based data structure available since earlier versions of java

HashMap is a hashing based key-value pair data structure
- allow one null as key
- allows multiple null as more than one value
- not thread safe

HashSet is a hashing based set representation
- holds unique set of keys
- internally uses HashMap
- allows one null value
- not thread safe

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More Advanced Java Interview Questions

How do you maintain a stateful session object across the session

2 Answers   HCL,


What is the main functionality of RRL(Remote Reference Layer)?

3 Answers  


What value does readline() return when it has reached the end of a file?

0 Answers  


How many JSP scripting elements and what are they?

4 Answers   TCS,


which type of objects reference will be given to client?

0 Answers  






Explain the life cycle of servlet?

3 Answers   Cognizant, HCL,


what is heepStored?

1 Answers  


what is the Scope of Final Keyword in Java?

1 Answers   HCL,


What is scalable, portability in the view of J2EE?

0 Answers  


Define the remote object implementation?

0 Answers  


Is infobus easy to use?

0 Answers  


In howmany ways a thread can be created?

3 Answers   HCL,


Categories