Java 8 Streams peek api

前端 未结 4 1941
暖寄归人
暖寄归人 2020-12-05 04:49

I tried the following snippet of Java 8 code with peek.

List list = Arrays.asList(\"Bender\", \"Fry\", \"Leela\");
list.stream().p         


        
4条回答
  •  暖寄归人
    2020-12-05 05:06

    From the docs on Stream for the peek method:

    ...additionally performing the provided action on each element as elements are consumed from the resulting stream.

提交回复
热议问题