Advanced Features in Java: Working with Sets In Java

Expected Duration
Lesson Objectives
Course Number
Expertise Level


In this course, you'll explore the Set interface and the different Set collections available in Java. You'll learn how the Java Set interface extends Collection, and how it is used to define unordered collections in which duplicates are not allowed. You'll discover common set operations such as union, difference, intersection, and equality, as well as how these are influenced heavily by the implementation of .equals and .hashCode in the objects contained within the set. You'll cover four implementations of the Set interface - HashSet, LinkedHashSet, EnumSet, and TreeSet. Finally, you'll learn the correct implementations of the .hashCode, .equals, and .compareTo methods of user-defined objects that are to be stored in Sets.

Expected Duration (hours)

Lesson Objectives

Advanced Features in Java: Working with Sets In Java

  • discover the key concepts covered in this course
  • create a HashSet object and invoke multiple methods on it, and also correctly override the .hashCode and .equals method of the contained class
  • describe how the HashSet behaves with duplicates and how overridden versions of the .equals and the .hashCode methods influence this behavior
  • recognize the different types of sets and how they all extend the Set, Collection, and Iterable interfaces
  • differentiate between methods used to compute set union, difference, intersection, and equality operations
  • analyze the performance characteristics of LinkedHashSets, TreeSets, and HashSets
  • recognize how and why EnumSets should be used to represent categorical data
  • describe how different implementations of the Set interface differ in their notions of set order
  • create a TreeSet and sort it using various custom comparators
  • create a TreeSet that stores custom objects without also creating a custom comparator
  • summarize the key concepts covered in this course
  • Course Number:

    Expertise Level