Here you can find the source of add(List
public static <E> List<E> add(List<E> list, E element)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static <E> List<E> add(List<E> list, E element) { if (element != null) { List<E> newList = new ArrayList<E>(); if (list != null) { newList.addAll(list);/*from w ww .ja va 2s. c o m*/ } newList.add(element); return newList; } return list; } }