@Test public void testJoin() { assertEquals("Hello World", StringUtils.join(Arrays.asList("Hello", "World"), " ")); assertEquals(" World", StringUtils.join(Arrays.asList("", "World"), " ")); assertEquals("Hello ", StringUtils.join(Arrays.asList("Hello", ""), " ")); }
public static String join(List<String> strings, String delimiter) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.size(); i++) { sb.append(strings.get(i)); if (i < strings.size()-1) { sb.append(delimiter); } } return sb.toString(); }
StringUtils { public static String join(List<String> strings, String delimiter) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.size(); i++) { sb.append(strings.get(i)); if (i < strings.size()-1) { sb.append(delimiter); } } return sb.toString(); } }
StringUtils { public static String join(List<String> strings, String delimiter) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.size(); i++) { sb.append(strings.get(i)); if (i < strings.size()-1) { sb.append(delimiter); } } return sb.toString(); } private  StringUtils(); }
StringUtils { public static String join(List<String> strings, String delimiter) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.size(); i++) { sb.append(strings.get(i)); if (i < strings.size()-1) { sb.append(delimiter); } } return sb.toString(); } private  StringUtils(); static String join(List<String> strings, String delimiter); }
StringUtils { public static String join(List<String> strings, String delimiter) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.size(); i++) { sb.append(strings.get(i)); if (i < strings.size()-1) { sb.append(delimiter); } } return sb.toString(); } private  StringUtils(); static String join(List<String> strings, String delimiter);  }