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

Connected

Exercise

Convert and collect unique cities

A travel agency stores city names in lowercase. Before displaying them in brochures, all city names need to be converted to uppercase and stored in a Set to ensure uniqueness.

All the necessary util and stream classes have been imported from you.

Instructions

100 XP
  • Convert each city name to an uppercase letter using .map().
  • Collect the result using .collect().
  • Collect the result in a Set using a predefined collect strategy.