finalList.addAll(listTwo);
Will add the elements from listTwo
into finalList
.
If you are getting a NullPointerException it is because one of your lists is null. Note that isEmpty()
will throw a NullPointerException if the list is null, so that probably won't help you.
To check if the lists are null, do listTwo == null
and/or finalList == null
.