Skip to content

Instantly share code, notes, and snippets.

@yavuztas
Last active August 27, 2019 15:24
Show Gist options
  • Save yavuztas/aaf5dff20294e0b4f5e8d3cf321ba74b to your computer and use it in GitHub Desktop.
Save yavuztas/aaf5dff20294e0b4f5e8d3cf321ba74b to your computer and use it in GitHub Desktop.
Created with Copy to Gist
public static <T> List<T> filterArray(T[] array, Predicate<? super T> predicate) {
return Arrays.stream(array)
.filter(predicate)
.collect(Collectors.toCollection(ArrayList::new));
}
public static <T> List<T> filterCollection(
Collection<T> collection, Predicate<? super T> predicate) {
return collection.stream()
.filter(predicate)
.collect(Collectors.toCollection(ArrayList::new));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment