Java List to Array toStringArray(List list)

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

Description

to String Array

License

Apache License

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static String[] toStringArray(List<String> list) {
        String[] data = new String[list.size()];
        for (int i = 0; i < data.length; i++)
            data[i] = list.get(i);/*from   ww w.  j av a2s  . c o m*/
        return data;
    }

    public static <T> T get(List<T> l, int i) {
        return get(l, i, null);
    }

    public static <T> T get(List<T> l, int i, T defValue) {
        if (i < 0)
            i += l.size();
        if (i < 0 || i >= l.size())
            return defValue;
        return l.get(i);
    }

    public static <T> T get(T[] l, int i) {
        return get(l, i, null);
    }

    public static <T> T get(T[] l, int i, T defValue) {
        if (i < 0)
            i += l.length;
        if (i < 0 || i >= l.length)
            return defValue;
        return l[i];
    }

    public static double get(double[] l, int i, double defValue) {
        if (i < 0)
            i += l.length;
        if (i < 0 || i >= l.length)
            return defValue;
        return l[i];
    }
}

Related

  1. toStringArray(List list)
  2. toStringArray(List objList)
  3. toStringArray(List array)
  4. toStringArray(List items)
  5. toStringArray(List list)
  6. toStringArray(List list)
  7. toStringArraySafe(List list)

  8. HOME | Copyright © www.java2s.com 2016