Android ArrayList to String Convert buildFromToString(ArrayList list)

Here you can find the source of buildFromToString(ArrayList list)

Description

Used to create a string which represents the objects in an array

License

Open Source License

Parameter

Parameter Description
result a parameter

Declaration

public static <T> String buildFromToString(ArrayList<T> list) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    /**/*www.j a  v a2 s .c o m*/
     * Used to create a string which represents the objects in an array
     * @param result
     * @return
     */
    public static <T> String buildFromToString(ArrayList<T> list) {
        StringBuilder ret = new StringBuilder();

        int count = 0;

        for (T t : list) {
            if (count != 0) {
                ret.append(", ");
            }
            ret.append(t.toString());
            count++;
        }

        return ret.toString();
    }
}