Last active
October 17, 2023 10:54
-
-
Save truongquoc/fe7fb684c0af9f225a470aae5ec8d7e5 to your computer and use it in GitHub Desktop.
Stream API
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
@Test | |
public void test() { | |
List<String> words = Arrays.asList("apple", "banana", "cherry", "date", "elderberry"); | |
// Declare a Stream that filters words starting with the letter 'a' | |
Stream<String> filteredWords = words.stream().peek(System.out::println).filter(word -> word.startsWith("a")); | |
filteredWords.forEach(System.out::println); | |
boolean isValidate = filteredWords.count() > 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment