1. Learn
  2. /
  3. Courses
  4. /
  5. Input/Output and Streams in Java

Connected

Exercise

Displaying city names

Managing sets of locations is a common task in applications like travel planning, navigation systems, or user-generated location sets. In this exercise, you will practice using an enhanced for-loop to display a set of cities. This approach ensures you can easily retrieve and process city names from a collection.

The HashSet class has been imported for you.

Instructions

100 XP
  • Use an enhanced for-loop to travel through the created set cities.
  • Print each city inside the loop.