static public String join ( String [ ] array , String sep , int from , int upto ) { if ( sep == null ) sep = "" ; if ( from < 0 || upto > array . length ) throw new IndexOutOfBoundsException ( ) ; if ( upto <= from ) return "" ; StringBuilder result = new StringBuilder ( ) ; boolean first = true ; for ( int i = from ; i < upto ; i ++ , first = false ) { if ( ! first ) result . append ( sep ) ; result . append ( array [ i ] ) ; } return result . toString ( ) ; }
Given an Array of Strings and a separator and a count concat the first count elements of an array with separator between them . A null string is treated like .