How to split a String into a Stream of Strings?

前端 未结 3 1212
北恋
北恋 2020-12-08 00:04

What is the best method of splitting a String into a Stream?

I saw these variations:

  1. Arrays.stream(\"b,l,a\".split(\",\"))
3条回答
  •  情书的邮戳
    2020-12-08 00:47

    Regarding (1) and (2) there shouldn't be much difference, as your code is almost the same.
    Regarding (3), that would be much more effective it terms of memory (not necessarily CPU), but in my opinion, a bit harder to read.

提交回复
热议问题