public String capitalize ( String words ) { if ( words == null ) return null ; String result = words . trim ( ) ; if ( result . length ( ) == 0 ) return "" ; if ( result . length ( ) == 1 ) return result . toUpperCase ( ) ; return "" + Character . toUpperCase ( result . charAt ( 0 ) ) + result . substring ( 1 ) . toLowerCase ( ) ; }
Returns a copy of the input with the first character converted to uppercase and the remainder to lowercase .