流的使用
無狀態:處理單個數據
有狀態:處理所有數據
| 中間操作(無狀態) | 中間操作(有狀態) | 終端操作(短路) | 終端操作(非短路) |
|---|---|---|---|
| 過濾(filter) | 去重(distinct) | 所有匹配(allMatch) | 遍歷(forEach) |
| 映射(map) | 跳過(skip) | 任意匹配(anyMatch) | 歸約(reduce) |
| 扁平化(flatMap) | 截斷(limit) | 不匹配(noneMatch) | 最大值(max) |
| 遍歷(peek) | 排序(sorted) | 查找首個(findFirst) | 最小值(min) |
| 查找任意(findAny) | 聚合(collect) | ||
| 計數(count) |