Here you can find the source of join(String glue, String... str)
Parameter | Description |
---|---|
glue | a parameter |
str | a parameter |
public static String join(String glue, String... str)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**/* w w w.j a v a 2s . com*/ * Combine strings with a common string * @param glue * @param str * @return A single string */ public static String join(String glue, String... str) { if (str.length > 0) { StringBuilder sb = new StringBuilder(str[0]); for (int i = 1; i < str.length; i++) sb.append(glue).append(str[i]); return sb.toString(); } else return ""; } /** * Combine a list of strings with a common string * @param glue * @param str * @return {@link #join(String,String...)} */ public static String join(String glue, List<String> str) { return join(glue, str.toArray(new String[str.size()])); } }