Convert list of String To a single String - Android java.lang

Android examples for java.lang:String Join

Description

Convert list of String To a single String

Demo Code

import java.util.List;

public class Main{


    public static String listToString(List<String> list) {
        StringBuilder sb = new StringBuilder();
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                if (i < list.size() - 1) {
                    sb.append(list.get(i) + ",");
                } else {
                    sb.append(list.get(i));
                }/*from  w  w w  .  j  av a 2 s  .  c o  m*/
            }
        }
        return sb.toString();
    }

}

Related Tutorials