Java Collection to String collectionToString(@SuppressWarnings("rawtypes") Collection coll)

Here you can find the source of collectionToString(@SuppressWarnings("rawtypes") Collection coll)

Description

Take a collection of anything and return it formatted as a string.

License

Open Source License

Parameter

Parameter Description
coll A collection of anything

Return

[ , ... ]

Declaration

static public String collectionToString(@SuppressWarnings("rawtypes") Collection coll) 

Method Source Code


//package com.java2s;
/*/*from w  ww  .  jav a2s. co  m*/
 * The contents of this file are subject to the Automated Business Logic Public License Version 1.0 (the "License"),
 * which is derived from the Mozilla Public License version 1.1. You may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at http://www.automatedbusinesslogic.com/license/public-license
 *
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, 
 * either express or implied. See the License for the specific language governing rights and limitations under the License.
 */

import java.util.Collection;

public class Main {
    /**
     * Take a collection of anything and return it formatted as a string.
     * @param coll A collection of anything
     * @return [ <object toString>, ... ]
     */
    static public String collectionToString(@SuppressWarnings("rawtypes") Collection coll) {
        if (coll == null)
            return "";
        StringBuffer sb = new StringBuffer();

        sb.append("[");
        for (Object o : coll) {
            sb.append(o.toString());
            sb.append(",");
        }
        sb.append("]");

        return sb.toString();
    }
}

Related

  1. collectionToDelimitedString(Collection values, String delimiter)
  2. collectionToStr(Collection collection)
  3. CollectionToStr(Collection coll)
  4. collectionToStr(Collection collection)
  5. collectionToString( Collection collection)
  6. collectionToString(Collection c)
  7. collectionToString(Collection c, String delim)
  8. collectionToString(Collection c, String spilt)
  9. collectionToString(Collection col)

HOME | Copyright © www.java2s.com 2016