Created
January 3, 2019 09:33
-
-
Save ohdoking/da4af7238f0945cdf6087dbc95505656 to your computer and use it in GitHub Desktop.
[Java]Reverse method in Stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> Collector<T, ?, Stream<T>> reverse() { | |
return Collectors.collectingAndThen(Collectors.toList(), list -> { | |
Collections.reverse(list); | |
return list.stream(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
reverse in Stream[java]
reference : https://www.techiedelight.com/reverse-sequential-stream-java/