Java 8: merge lists with stream API

前端 未结 3 412
死守一世寂寞
死守一世寂寞 2020-12-07 22:17

I have the following situation

Map map; 

public class ListContainer{
  List lst;
}

I have to merge

3条回答
  •  春和景丽
    2020-12-07 22:52

    In Java 8 we can use stream List1.stream().collect(Collectors.toList()).addAll(List2); Another option List1.addAll(List2)

提交回复
热议问题