Here you can find the source of add(List
static <T> List<T> add(List<T> list, T element)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { static <T> List<T> add(List<T> list, T element) { final ArrayList<T> result = new ArrayList<T>(list.size() + 2); result.addAll(list);/*from ww w .j a v a2s. c om*/ result.add(element); return result; } }