Java Collection Convert convert(Collection c)

Here you can find the source of convert(Collection c)

Description

convert

License

Apache License

Declaration

public static String[] convert(Collection<String> c) 

Method Source Code


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

import java.util.ArrayList;
import java.util.Collection;

import java.util.List;

public class Main {
    public static String[] convert(Collection<String> c) {
        if (c == null)
            return null;

        String[] r = new String[c.size()];
        int i = 0;
        for (String s : c) {
            r[i] = s;/*from ww w.  j a  v  a  2s.  c  o m*/
            i++;
        }
        return r;
    }

    public static List<String> convert(String[] c) {
        List<String> l = new ArrayList<String>();
        if (c != null) {
            for (String s : c) {
                if (s != null) {
                    l.add(s);
                }
            }
        }
        return l;
    }
}

Related

  1. convert(Collection list)
  2. convert2IntegerCollection(String[] strs)
  3. convertArrayInCollection(String[] array)
  4. convertCharCollectionToArray(Collection chars)
  5. convertCollectionInArray(Collection coll)