Here you can find the source of join(ArrayList
Parameter | Description |
---|---|
strings | The strings to join |
separator | A separator |
public static String join(ArrayList<String> strings, String separator)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { /**//from w w w.j a v a2 s .c o m * Join an array * @param strings The strings to join * @param separator A separator * @return */ public static String join(ArrayList<String> strings, String separator) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < strings.size(); i++) { if (i != 0) sb.append(separator); sb.append(strings.get(i)); } return sb.toString(); } }