Here you can find the source of concatenate(String[] strings, String sep)
Parameter | Description |
---|---|
strings | an array of string |
sep | the separator |
public static String concatenate(String[] strings, String sep)
//package com.java2s; import java.util.Arrays; import java.util.List; public class Main { /**//from w w w .j av a 2s . c om * Concatenate a list of strings. * * @param strings a list of string * @param sep the separator * @return the concatenation of the list of string. */ public static String concatenate(List<String> strings, String sep) { String str = ""; for (String s : strings) { if (str.equals("")) { str = s; } else { str += sep + s; } } return str; } /** * Concatenate an array of strings. * * @param strings an array of string * @param sep the separator * @return the concatenation of the list of string. */ public static String concatenate(String[] strings, String sep) { return concatenate(Arrays.asList(strings), sep); } }