Skip to content

Instantly share code, notes, and snippets.

@Jayasagar
Created December 17, 2017 15:14
Show Gist options
  • Save Jayasagar/930a92769da9bd8f9cbd477a01224540 to your computer and use it in GitHub Desktop.
Save Jayasagar/930a92769da9bd8f9cbd477a01224540 to your computer and use it in GitHub Desktop.
boolean isAnyConsumerInBerlin = consumerList
.stream()
// anyMatch terminal operation
.anyMatch(consumer -> "Berlin".equals(consumer.getCity()));
System.out.println(String.format("Are there any user based in Berlin: %b", isAnyConsumerInBerlin));
// Output: Are there any user based in Berlin:true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment