How to code Stream.findNth()?

后端 未结 1 444
太阳男子
太阳男子 2020-12-10 20:18

Similar to Stream.findFirst(), is there a way to write Stream.findNth()?

I\'m practicing Java 8 by rewriting some legacy code. And, I\'m wo

1条回答
  •  佛祖请我去吃肉
    2020-12-10 20:57

    OptionalInt result = stream.skip(n-1).findFirst();
    

    0 讨论(0)
提交回复
热议问题