Here you can find the source of Join(ArrayList
Parameter | Description |
---|---|
list | List of String objects |
delimiter | Delimiter |
public static String Join(ArrayList<String> list, String delimiter)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { /** This method converts a list of String objects to a single String representation and inserts a delimiter between each object. * /*from ww w .j a v a2 s .c o m*/ * @param list List of String objects * @param delimiter Delimiter * @return Formatted String representation */ public static String Join(ArrayList<String> list, String delimiter) { if (list.isEmpty()) return ""; StringBuilder sb = new StringBuilder(); for (String x : list) sb.append(x + delimiter); sb.delete(sb.length() - delimiter.length(), sb.length()); return sb.toString(); } }