Java List Prepend prepend(List list, E e)

Here you can find the source of prepend(List list, E e)

Description

prepend

License

Open Source License

Declaration

public static <E> List<E> prepend(List<E> list, E e) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static <E> List<E> prepend(List<E> list, E e) {
        List<E> newList = new ArrayList<>(list);

        newList.add(0, e);/*from  w w  w.  j av a 2 s .c  o m*/

        return newList;
    }
}

Related

  1. prepend(final List list, final int numElements, final T element)
  2. prepend(final List suffix, final T... values)
  3. prepend(final T value, final List list)
  4. prepend(List list, int minCapacity, E... items)
  5. prepend(String clang, List args)
  6. prepend(String prefix, List strings)
  7. prepend(String start, List suggestions)