Stream API for Collections in Java


Use the Stream API to process collections in a declarative way.

Source Code

List myList = Arrays.asList("a1", "a2", "b1", "c2", "c1");
myList.stream()
      .filter(s -> s.startsWith("c"))
      .map(String::toUpperCase)
      .sorted()
      .forEach(System.out::println); // C1 C2
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments