Splitting List into sublists along elements

后端 未结 13 1952
野趣味
野趣味 2020-11-28 21:51

I have this list (List):

[\"a\", \"b\", null, \"c\", null, \"d\", \"e\"]

And I\'d like something like this:

13条回答
  •  忘掉有多难
    2020-11-28 22:45

    Here is code by AbacusUtil

    List list = N.asList(null, null, "a", "b", null, "c", null, null, "d", "e");
    Stream.of(list).splitIntoList(null, (e, any) -> e == null, null).filter(e -> e.get(0) != null).forEach(N::println);
    

    Declaration: I'm the developer of AbacusUtil.

提交回复
热议问题