Java Vector Create toVector(T[] array)

Here you can find the source of toVector(T[] array)

Description

Creates a vector and fills it with the elements of the specified array.

License

Open Source License

Parameter

Parameter Description
array the array of elements

Declaration

public static <T> Vector<T> toVector(T[] array) 

Method Source Code

//package com.java2s;
/*// w  w  w  .ja v a 2 s .  c  o m
 * Copyright (C) 1990-2001 DMS Decision Management Systems Ges.m.b.H.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * $Id: Utils.java,v 1.56 2008-11-02 02:01:43 mgordon Exp $
 */

import java.util.*;

public class Main {
    /**
     * Creates a vector and fills it with the elements of the specified array.
     *
     * @param   array       the array of elements
     */
    public static <T> Vector<T> toVector(T[] array) {
        if (array == null) {
            return new Vector<T>();
        } else {
            Vector<T> vector = new Vector<T>(array.length);

            for (int i = 0; i < array.length; i++) {
                vector.addElement(array[i]);
            }
            return vector;
        }
    }
}

Related

  1. parseLinesFromLast(byte[] bytearray, int lineCount, Vector lastNlines)
  2. tokenVector(String s, String delimiters)
  3. ToVector(byte[] in)
  4. toVector(Enumeration pEnumeration_)
  5. toVector(Object[] array)