ArrayUtils { public static String join( String delimiter, String... strings ) { return join( delimiter, Arrays.asList( strings ) ); }  static String[] removeAll( String[] array, String token ); static String join( String delimiter, String... strings ); static String join( String delimiter, Object... objects ); static String join( String delimiter, Collection<?> objects ); static String join( String delimiter, int[] values ); static String join( String delimiter, double[] values ); static boolean contains( String[] target, String value, boolean caseSensitive, boolean exact ); static boolean contains( String[] target, String value ); static String[] toArray( String s, String delimiter, boolean deleteDoubles ); static List<String> toList( String s, String delimiter, boolean deleteDoubles ); static String[] deleteDoubles( String[] s ); static ArrayList<Integer> splitAsIntList( String str, String delim ); static double[] splitAsDoubles( String str, String delim ); static float[] splitAsFloats( String str, String delim ); static void sortByLengthDescending( String[] strings );  }
@Test public void testJoin() { assertEquals( "foo|bar|baz", join( "|", "foo", "bar", "baz" ) ); assertEquals( "foo|bar|baz", join( "|", new String[] { "foo", "bar", "baz" } ) ); String[] test = new String[] { "foo", "bar", "baz" }; assertEquals( "foo|bar|baz", join( "|", test ) ); }
@Test public void testJoinList() { List<String> list1 = new LinkedList<String>(); list1.add( "foo" ); list1.add( "bar" ); list1.add( "baz" ); assertEquals( "foo|bar|baz", join( "|", list1 ) ); List<String> list2 = new ArrayList<String>( 3 ); list2.add( "foo" ); list2.add( "bar" ); list2.add( "baz" ); assertEquals( "foo | bar | baz", join( " | ", list2 ) ); }
@Test public void testjoinInts() { int[] arr1 = new int[] { 1, 2, 3, 4, 5 }; assertEquals( "1, 2, 3, 4, 5", ArrayUtils.join( ", ", arr1 ) ); assertEquals( "1,2,3,4,5", ArrayUtils.join( ",", arr1 ) ); assertEquals( "12345", ArrayUtils.join( "", arr1 ) ); assertEquals( "", ArrayUtils.join( ",", new int[] {} ) ); }