Here you can find the source of cons(P first, List extends P> list)
public static <P> List<P> cons(P first, List<? extends P> list)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static <P> List<P> cons(P first, List<? extends P> list) { List<P> builder = new ArrayList<>(list.size() + 1); builder.add(first);// w ww. j a va 2 s. c o m builder.addAll(list); return builder; } }