join List of string to string - Android java.lang

Android examples for java.lang:String Join

Description

join List of string to string

Demo Code

import java.util.List;

public class Main{

    public static String join(String separator, List<String> data) {
        StringBuilder sb = new StringBuilder();
        for (String item : data) {
            if (sb.length() > 0)
                sb.append(separator);/*w w  w  . j  a va2 s  .c om*/
            sb.append(item);
        }
        return sb.toString();
    }

}

Related Tutorials