Can the input parameter of the List.addAll method be null?

Reading the source code comments of List shows that if one or more elements in the collection of addAll are empty or the collection is empty, a null pointer exception will be thrown.
insert image description here
Take a look at the method of the concrete implementation class.
insert image description here
ArrayList.addAll, if the collection is empty, a null pointer exception will be thrown.
insert image description here
It can be seen that when using the addAll method, it should be judged that the input parameter set is null

Guess you like

Origin blog.csdn.net/qq_44624722/article/details/118539849