Skip to content

Instantly share code, notes, and snippets.

@Jayasagar
Created December 17, 2017 15:13
Show Gist options
  • Save Jayasagar/7b2bac0526ad9ad564f7cd456fe2eb87 to your computer and use it in GitHub Desktop.
Save Jayasagar/7b2bac0526ad9ad564f7cd456fe2eb87 to your computer and use it in GitHub Desktop.
List<String> uniqueCities = consumerList
.stream()
.map(Consumer::getCity)
.distinct()
.collect(Collectors.toList());
System.out.println(uniqueCities);
// Output: [Hyd, Berlin]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment