private static void appendToSentence ( StringBuilder buf , String [ ] names ) { for ( int i = 0 ; i < names . length ; i ++ ) { if ( i > 0 ) { if ( i + 1 >= names . length ) { buf . append ( " or " ) ; } else { buf . append ( ", " ) ; } } buf . append ( ' ' ) ; buf . append ( names [ i ] ) ; buf . append ( ' ' ) ; } }
Appends words to a sentence as an or list .