@Test public void testJoin() { assertThat(join(Arrays.asList("a ", "b ", " c "), ","), is("a,b,c")); assertThat(join(Arrays.asList("a", "b", "c", "d"), ","), is("a,b,c,d")); assertThat(join(Arrays.asList("a ", "b ", " c "), ", "), is("a, b, c")); assertThat(join(Arrays.asList("a", "b", "c", "d"), ", "), is("a, b, c, d")); }
public static <T> String join(List<T> list, String separator, Function<T, String> function) { String result = ""; for (int i = 0; i < list.size(); i++) { result += function.apply(list.get(i)).trim(); if (i + 1 < list.size()) { result += separator; } } return result; }
Collection { public static <T> String join(List<T> list, String separator, Function<T, String> function) { String result = ""; for (int i = 0; i < list.size(); i++) { result += function.apply(list.get(i)).trim(); if (i + 1 < list.size()) { result += separator; } } return result; } }
Collection { public static <T> String join(List<T> list, String separator, Function<T, String> function) { String result = ""; for (int i = 0; i < list.size(); i++) { result += function.apply(list.get(i)).trim(); if (i + 1 < list.size()) { result += separator; } } return result; } private  Collection(); }
Collection { public static <T> String join(List<T> list, String separator, Function<T, String> function) { String result = ""; for (int i = 0; i < list.size(); i++) { result += function.apply(list.get(i)).trim(); if (i + 1 < list.size()) { result += separator; } } return result; } private  Collection(); static String[] tail(String[] args); @SafeVarargs static T[] create(T... args); static String join(List<T> list, String separator, Function<T, String> function); static String join(List<String> list, String separator); }
Collection { public static <T> String join(List<T> list, String separator, Function<T, String> function) { String result = ""; for (int i = 0; i < list.size(); i++) { result += function.apply(list.get(i)).trim(); if (i + 1 < list.size()) { result += separator; } } return result; } private  Collection(); static String[] tail(String[] args); @SafeVarargs static T[] create(T... args); static String join(List<T> list, String separator, Function<T, String> function); static String join(List<String> list, String separator);  }