mirror of
https://github.com/sjsdfg/effective-java-3rd-chinese.git
synced 2025-01-30 06:10:10 +08:00
47. 优先使用 Collection 而不是 Stream 来作为方法的返回类型
This commit is contained in:
parent
7848d43ed5
commit
8341a59b04
@ -22,7 +22,7 @@ for (ProcessHandle ph : ProcessHandle.allProcesses()::iterator) {
|
||||
|
||||
为了使代码编译,必须将方法引用强制转换为适当参数化的 `Iterable` 类型:
|
||||
|
||||
```Java`此处输入代码`
|
||||
```Java
|
||||
// Hideous workaround to iterate over a stream
|
||||
for (ProcessHandle ph : (Iterable<ProcessHandle>)ProcessHandle.allProcesses()::iterator)
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user