Java Collection to String toString(Collection collection)

Here you can find the source of toString(Collection collection)

Description

Returns a String representation of the input collection by calling each element's toString() method.

License

Open Source License

Parameter

Parameter Description
T a parameter
collection a parameter

Declaration

public static <T> Collection<String> toString(Collection<T> collection) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;

import java.util.Collection;

public class Main {
    /**/*from  www  . j  av  a 2 s.c  o  m*/
     * Returns a String representation of the input collection by calling each
     * element's toString() method.
     * 
     * @param <T>
     * @param collection
     * @return
     */
    public static <T> Collection<String> toString(Collection<T> collection) {
        Collection<String> strings = new ArrayList<String>();
        for (T item : collection)
            strings.add(item.toString());
        return strings;
    }
}

Related

  1. toString(Collection collection)
  2. toString(Collection strings)
  3. toString(Collection a, String begStr, String sepStr, String endStr)
  4. toString(Collection collection)
  5. toString(Collection collection)
  6. toString(Collection collection)
  7. toString(Collection collection, String divider)
  8. toString(Collection list, String delimeter)
  9. toString(final Collection collection)

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