create Vector from varargs - Java java.util

Java examples for java.util:Vector

Description

create Vector from varargs

Demo Code


//package com.book2s;

import java.util.Collection;

import java.util.Vector;

public class Main {

    public static final <E> Vector<E> createVector(E... elements) {
        Vector<E> list = new Vector<E>();
        addToCollection(list, elements);
        return list;
    }/*  w ww .  ja  va  2  s  .c om*/

    public static final <E> void addToCollection(
            Collection<? super E> collection, E... elements) {
        for (E e : elements) {
            collection.add(e);
        }
    }
}

Related Tutorials