• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

What is the difference between HashSet and HashTable?  RSS feed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

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


Thanks a lot.....
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!