1. Learn
  2. /
  3. Courses
  4. /
  5. Data Types and Exceptions in Java

Connected

Exercise

Working with HashSet

Create a HashSet to hold a list of heights in inches (Integer), add some new heights, and replace one of the heights with null (to see that Set allows for null objects).

Instructions

100 XP
  • Import HashSet for use in the application.
  • Construct a new HashSet of Integers and set the heights variable to it.
  • Add a new height, 64, to the heights list.
  • Replace 64 with null.