Java Scrap Book  

Java Scrap Book > Overview of HashSet

Overview of HashSet

HashSet is implementation of Set Interface with following attribute

  1. HashSet does not guarantees as to the iteration order of the HashSet.
  2. HashSet does not guarantees that the order will remain constant over times.
  3. HashSet permits only one null value.
  4. HashSet has constant time performance for the basic operations (add, remove, contains and size),

Set and HashSet

package com.javascrapbook.hashset;
import java.util.HashSet;
import  java.util.Set;
public class  HashSetDemo {
   public static void main(String[] a) {
     Set set = new HashSet();
     if (set.add("book")) {
     System.out.println("addition successful");
  }   else {
     System.out.println("addition failed");

Copyright © 2013-2019 is a computer science content service should not be treated as the publisher or speaker of any information provided by another Computer Science content provider.

Contact email: