• HashSet is the implementation class of the Set interface which is also used to store groups of individual objects but duplicate values are not allowed.
  • HashSet internally follows a hashtable structure where all the elements are stored using a hashing technique which will Improve the performance by reducing the waiting time. 
  • HashSet is not a synchronized class.
  • HashSet supports only one null value.
  • HashSet is called an unordered Collection because it is not guaranteed for insertion order of elements.

Creation of HashSet:

HashSet<E> hs= new HashSet<E>();
HashSet<E> hs = new HashSet<E>(int capacity);
HashSet<E> hs = new HashSet<E>(int capacity, float loadfactor):
HashSet<E> hs = new HashSet<E>(Collection obj);


  • boolean add(E obj)
  • boolean remove(E obj)
  • int size()
  • void clear()
  • boolean contains(E obj)
  • boolean isEmpty()

Post a Comment

* Please Don't Spam Here. All the Comments are Reviewed by Admin.