Java Collection to String toStrings(Collection vals)

Here you can find the source of toStrings(Collection vals)

Description

to Strings

License

Apache License

Parameter

Parameter Description
vals a parameter

Declaration

public static String[] toStrings(Collection vals) 

Method Source Code


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

import java.util.Collection;
import java.util.Iterator;

public class Main {
    /**//  w ww.j  a v  a  2 s .com
     * @param vals
     * @return
     */
    public static String[] toStrings(Collection vals) {
        int size = vals.size(), cnt = 0;
        String[] strings = new String[size];

        for (Iterator itr = vals.iterator(); itr.hasNext();) {
            String s = (String) itr.next();
            if (s != null) {
                strings[cnt] = s;
                cnt++;
            }
        }
        return strings;
    }
}

Related

  1. toString(final Collection objs)
  2. toString(final Collection values)
  3. toString(final Collection list, final String delimiter)
  4. toString(final Collection c)
  5. toString(String[] collection, char separator)
  6. toStrings(Collection c)
  7. toStrings(Collection objects)
  8. toStrings(final Collection stringCollection)
  9. toStringWithDelimiters(Collection objects, String delim)