public static String capitalize ( final String input ) throws IllegalArgumentException { if ( input == null ) { throw new IllegalArgumentException ( "input can't be null" ) ; } if ( input . length ( ) == 0 ) { return "" ; } return head ( input ) . map ( String :: toUpperCase ) . map ( h -> tail ( input ) . map ( t -> h + t . toLowerCase ( ) ) . orElse ( h ) ) . get ( ) ; }
Converts the first character of string to upper case and the remaining to lower case .