Strings { public static String join(String delim, Object[] objects) { if (objects.length == 0) return ""; return join(new StringBuilder(), delim, objects).toString(); }  static String join(String delim, Object[] objects); static StringBuilder join(StringBuilder builder, String delim, Object[] objects); static StringBuilder join(StringBuilder builder, String delim, Iterable<?> objects);  }
@Test public void testJoin() { assertEquals("", Strings.join(", ", new Object[0])); assertEquals("1", Strings.join(", ", new Object[]{1})); assertEquals("1, 2", Strings.join(", ", new Object[]{1, 2})); }
@Test public void testJoin_withStringBuilder() { assertEquals("", Strings.join(new StringBuilder(), ", ", new Object[0]).toString()); assertEquals("1", Strings.join(new StringBuilder(), ", ", new Object[]{1}).toString()); assertEquals("1, 2", Strings.join(new StringBuilder(), ", ", new Object[]{1, 2}).toString()); }