| 知乎专栏 |
package cn.netkiller.test;
import lombok.Data;
import java.io.IOException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Data
public class Test {
public static void main(String[] args) throws IOException {
Stream.of("one", "two", "three", "four").filter(e -> e.length() > 3)
.peek(e -> System.out.println("Before value: " + e))
.map(String::toUpperCase)
.peek(e -> System.out.println("After value: " + e))
.collect(Collectors.toList());
}
}