Collect HashSet / Java 8 / Regex Pattern / Stream API

后端 未结 6 805
日久生厌
日久生厌 2020-12-29 09:42

Recently I change version of the JDK 8 instead 7 of my project and now I overwrite some code snippets using new features that came with Java 8.

final Matcher         


        
6条回答
  •  长情又很酷
    2020-12-29 10:36

    I don't think you can turn this into a Stream without writing your own Spliterator, but, I don't know why you would want to.

    Matcher.find() is a state changing operation on the Matcher object so running each find() in a parallel stream would produce inconsistent results. Running the stream in serial wouldn't have better performance that the Java 7 equivalent and would be harder to understand.

提交回复
热议问题