aspose file tools*
The moose likes Beginning Java and the fly likes What is the difference between HashSet  and HashTable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is the difference between HashSet  and HashTable?" Watch "What is the difference between HashSet  and HashTable?" New topic
Author

What is the difference between HashSet and HashTable?

Deepika Singh
Greenhorn

Joined: Oct 10, 2008
Posts: 21
Hi all,

Could anyone tell me the difference between HashSet and HashTable, Comparator and Comparable, Array and Collections.


Thanks a lot.....
Arka Guhathakurta
Ranch Hand

Joined: Mar 01, 2009
Posts: 46
HashSet is a Set and Hashtable is a Map. You have to read Set and Map interfaces to know the difference. You use Comparable's compareTo method to compare two objects of a class. That basically menas that implementing a comparable interface will make your class to be used to calculate HashCode. However comparator can be used to compare one or more objects. Array is a contiguous collection of similar data-types (generally) whereas collection is a type safe arrangement of objects. Collections framework will tell more. Please correct me if I am wrong.


regards,
Arka
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Deepika Singh wrote:Could anyone tell me the difference between HashSet and HashTable, Comparator and Comparable, Array and Collections.

Have you looked at the JavaDocs for those classes?
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

Arka Guhathakurta wrote:HashSet is a Set and Hashtable is a Map. You have to read Set and Map interfaces to know the difference. You use Comparable's compareTo method to compare two objects of a class. That basically menas that implementing a comparable interface will make your class to be used to calculate HashCode. However comparator can be used to compare one or more objects. Array is a contiguous collection of similar data-types (generally) whereas collection is a type safe arrangement of objects. Collections framework will tell more. Please correct me if I am wrong.


A small adding for what Arka said A Set is a collection that has no duplicate elements. A map is a way of storing key/value pairs. The way of storing a Map is similar to two-column table and for detailed information see java documentation


Thanks,
Sherif
 
 
subject: What is the difference between HashSet and HashTable?