Strings { public static String join(List<String> src, String delimiter) { if (src != null) { StringBuilder builder = new StringBuilder(); if (!src.isEmpty()) { builder.append(src.get(0)); } for (int i = 1; i < src.size(); i++) { builder.append(delimiter).append(src.get(i)); } return builder.toString(); } return null; } private  Strings(); static String toCsv(List<String> src); static String join(List<String> src, String delimiter); static String capitaliseFirstLetter(String string); static String lowercaseFirstLetter(String string); static String zeros(int n); static String repeat(char value, int n); static boolean isEmpty(String s);  }
@Test public void testJoin() { assertThat(join(Arrays.asList("a", "b"), "|"), is("a|b")); assertNull(join(null, "|")); assertThat(join(Collections.singletonList("a"), "|"), is("a")); }