Java ArrayList to Array toArray(ArrayList sigs)

Here you can find the source of toArray(ArrayList sigs)

Description

to Array

License

Open Source License

Declaration

private static String[] toArray(ArrayList<String> sigs) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2002 - 2006 IBM Corporation.
 * 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
 *
 * Contributors://from  w  ww.  j  a  v  a  2s.  c  om
 * IBM Corporation - initial API and implementation
 *******************************************************************************/

import java.util.ArrayList;

import java.util.Iterator;

public class Main {
    private static String[] toArray(ArrayList<String> sigs) {
        int size = sigs.size();
        if (size == 0) {
            return new String[0];
        }
        Iterator<String> it = sigs.iterator();
        String[] result = new String[size];
        for (int j = 0; j < size; j++) {
            result[j] = it.next();
        }
        return result;
    }
}

Related

  1. doubleArrayList2Array(ArrayList a)
  2. listToArray(ArrayList tempList)
  3. listToIntArray(ArrayList list)
  4. toArray(ArrayList arrayList)
  5. toArray(ArrayList arrlist)
  6. toBooleanArray(ArrayList items)
  7. toByteArray(ArrayList in)
  8. toIntArray(ArrayList list)
  9. toIntArray(ArrayList array)