public static String toTitleCase ( String string ) { Check . notNull ( string ) ; final int length = string . length ( ) ; final StringBuilder result = new StringBuilder ( length ) ; for ( int i = 0 ; i < length ; i ++ ) { final String next = string . substring ( i , i + 1 ) ; if ( i == 0 ) { result . append ( next . toUpperCase ( Locale . ENGLISH ) ) ; } else { result . append ( next . toLowerCase ( Locale . ENGLISH ) ) ; } } return result . toString ( ) ; }
Convert a string to title case .