Java List to Array asArray(List list)

Here you can find the source of asArray(List list)

Description

as Array

License

Open Source License

Declaration

public static String[] asArray(List<String> list) 

Method Source Code


//package com.java2s;
/*/*w  w w.jav  a2 s.co m*/
 * Copyright (C) 2008-2011 by Simon Hefti. All rights reserved.
 * Licensed under the EPL 1.0 (Eclipse Public License).
 * (see http://www.eclipse.org/legal/epl-v10.html)
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
 * 
 * Initial Developer: Simon Hefti
 */

import java.util.List;

public class Main {
    public static String[] asArray(List<String> list) {
        if (null == list) {
            return null;
        }
        String[] res = new String[list.size()];
        list.toArray(res);
        return res;

    }
}

Related

  1. asArray(Collection list)
  2. asArray(List values)
  3. asArray(List indices)
  4. asArray(List list)
  5. asArrayList(E first, E... other)
  6. asArrayList(T... a)
  7. asBooleanArray(List list)