Java Array to List toList(T[] array)

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

Description

to List

License

Open Source License

Declaration

public static <T> List<T> toList(T[] array) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014,2015 Hideki Yatomi
 * All rights reserved. This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/

import java.util.*;

public class Main {
    public static <T> List<T> toList(T[] array) {
        List<T> list = new ArrayList<>();
        Collections.addAll(list, array);
        return list;
    }//from   w  w w  .  j  av a 2  s  .  c  o m

    public static <T> List<T> toList(Iterator<T> it) {
        List<T> list = new ArrayList<>();
        while (it.hasNext()) {
            list.add(it.next());
        }
        return list;
    }
}

Related

  1. toList(T... objects)
  2. toList(T... objects)
  3. toList(T[] _array)
  4. toList(T[] anArrayToConvert)
  5. toList(T[] arr)
  6. toList(T[] array)
  7. toList(T[] array)
  8. toList(T[] array)
  9. toList(T[] array)