Here you can find the source of join(String[] strings)
Parameter | Description |
---|---|
strings | an array of strings |
public static String join(String[] strings)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { /**/* www.j av a 2s .c om*/ * @param strings an array of strings * @return all strings in the given array concatenated. * null if the array is null or empty. */ public static String join(String[] strings) { return join(strings, null); } /** * @param strings an array of strings * @param joinString a string (null or empty for nothing) * @return all strings in the given array concatenated, with <code>joinString</code> between each. * null if the array is null or empty. */ public static String join(String[] strings, String joinString) { if (strings == null || strings.length == 0) return null; StringBuffer b = new StringBuffer(); for (String str : strings) { if (str != null) { b.append(str); if (joinString != null) b.append(joinString); } } return b.toString(); } /** * @param strings a list of strings * @param joinString a string (null or empty for nothing) * @return all strings in the given array concatenated, with <code>joinString</code> between each. * null if the array is null or empty. */ public static String join(List<String> strings, String joinString) { if (strings == null || strings.size() == 0) return null; StringBuffer b = new StringBuffer(); for (String str : strings) { if (str != null) { b.append(str); if (joinString != null) b.append(joinString); } } return b.toString(); } }