Strings { public static String join(String separator, List<String> components) { if (components == null) { throw new IllegalArgumentException("list cannot be null"); } if (separator == null) { separator = ""; } StringBuilder sb = new StringBuilder(); for (String comp : components) { if (comp == null) { continue; } if (sb.length() > 0) { sb.append(separator); } sb.append(comp); } return sb.toString(); }  static List<String> split(String str, String separator); static String join(String separator, List<String> components); static String join(String separator, String... components);  }
@Test public void joinEmptyStrings() { assertEquals(Strings.join("."), ""); assertEquals(Strings.join(".", ""), ""); assertEquals(Strings.join(".", "", null), ""); assertEquals(Strings.join(".", "", null, "", null), ""); }
@Test public void joinWithEmptyStrings() { assertEquals(Strings.join(".", null, "", null, "a", "b", "", "c", "d"), "a.b..c.d"); }