• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

What is the difference between HashSet and HashTable?

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic