0) {finalList.addAll(list);}}return finalList;}..." />

Java merge lists function throws warning Unchecked generics array creation for varargs

I created a method to merge lists. IntelliJ is giving me a warning Unchecked generics array creation for varargs parameter when the method is used. Why is that happening?

/**

* Merge lists into a single list.

*

* @param lists

* @param

* @return

* @throws NullPointerException if lists are null.

*/

public static List merge(List... lists) {

if(lists == null) throw new NullPointerException("No lists provided");

final List finalList = new ArrayList<>();

for (List list : lists) {

if (list != null && list.size() > 0) {

finalList.addAll(list);

}

}

return finalList;

}...

Read More »

By: StackOverFlow - 5 days ago

Related Posts