Skip to content

簡介

public interface BaseStreamS extends BaseStream\> extends AutoCloseable public interface Stream extends BaseStreamStream<T>>

S同樣是stream,裡面不同(新的流對象)=> Stream<T>

S sequential();  // 調用sequential,返回一個新流
Stream<T> peek(Consumer<? super T> action); // 調用peek,返回一個新流
  • A sequence of elements supporting sequential and parallel aggregate operations.

內容

AutoCloseable

try (Stream<String> stream = list.stream()) {
  stream.onClose(() -> {
    System.out.println("1");
    throw new NullPointerException("1 exception");
  }).onClose(() -> {
    System.out.println("2");
    throw new NullPointerException("2 exception");
  }).forEach(System.out::println);
}

AbstractPipeline

Abstract base class for "pipeline" classes, which are the core implementations of the Stream interface and its primitive specializations. Manages construction and evaluation of stream pipelines. AbstractPipeline

TerminalOp

TerminalOp

參考資料