public static < E > StringBuffer join ( String glue , Collection < E > charSequences ) { StringBuffer buf = new StringBuffer ( ) ; int i = 0 ; for ( Object charSequence : charSequences ) { if ( i > 0 ) { buf . append ( glue ) ; } buf . append ( charSequence ) ; i ++ ; } return buf ; }
Takes a string glue and collection of CharSequences and returns a StringBuffer containing the CharSequences joined with the glue between each of them . They are joined in the order returned by the iterator of the colection