Here you can find the source of join(List
Parameter | Description |
---|---|
p_sStrList | string list |
p_sDelimiter | delimiter |
public static String join(List<String> p_sStrList, String p_sDelimiter)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { /**//from w w w . j a v a 2 s .c om * The method concatenates a list of strings with the given delimiter * * @param p_sStrList string list * @param p_sDelimiter delimiter * @return concatenated strings */ public static String join(List<String> p_sStrList, String p_sDelimiter) { StringBuilder sb = new StringBuilder(); for (String sCurrStr : p_sStrList) { if (sb.length() > 0) sb.append(p_sDelimiter); sb.append(sCurrStr); } return sb.toString(); } }