What is the Set interface?

  • The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.
  • Set also extends Collection, but it prohibits duplicate items (this is what defines a Set).
  • No new methods are introduced; specifically, none for index-based operations (elements of Sets are not ordered).
  • Concrete Set implementations contain methods that forbid adding two equal Objects.
  • More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element
  • Java has two implementations: HashSet, TreeSet


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email