Creates a new empty LinkedList with the inferred type. - Java java.util

Java examples for java.util:List Creation

Description

Creates a new empty LinkedList with the inferred type.

Demo Code


//package com.book2s;

import java.util.LinkedList;

public class Main {
    public static void main(String[] argv) {
        System.out.println(llist());
    }/* w w  w .j a va  2  s.c  om*/

    /**
     * Creates a new empty {@link LinkedList} with the inferred type.
     */
    public static <T> LinkedList<T> llist() {
        return new LinkedList<T>();
    }

    /**
     * Creates a new {@link LinkedList} with the inferred type
     * using the given elements.
     */
    @SafeVarargs
    public static <T> LinkedList<T> llist(T... vals) {
        LinkedList<T> ret = new LinkedList<T>();
        for (T v : vals)
            ret.add(v);
        return ret;
    }
}

Related Tutorials