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<Integer> list) 

Method Source Code

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

import java.util.List;

public class Main {
    public static String[] toStringArray(List<Integer> list) {
        if (isEmpty(list)) {
            return null;
        }/*from   w w  w  .j  a  va 2s . com*/
        String[] fields = new String[list.size()];
        int index = 0;
        for (Integer num : list) {
            fields[index] = Integer.toString(num);
            index++;
        }
        return fields;
    }

    public static boolean isEmpty(List<?> list) {
        if (list == null || list.isEmpty()) {
            return true;
        } else {
            return false;
        }
    }

    public static int size(Object[] list) {
        if (list == null) {
            return 0;
        } else {
            return list.length;
        }
    }

    public static int size(List<?> list) {
        if (list == null) {
            return 0;
        } else {
            return list.size();
        }
    }
}

Related

  1. toObjectArrayNative(List L)
  2. toStringArray(final List stringList)
  3. toStringArray(final List list)
  4. toStringArray(List l)
  5. toStringArray(List list)
  6. toStringArray(List objList)
  7. toStringArray(List array)
  8. toStringArray(List items)
  9. toStringArray(List list)

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