private static String capitalise ( String s ) { if ( s . length ( ) == 0 ) { return s ; } StringBuilder s1 = new StringBuilder ( s ) ; if ( Character . isLowerCase ( s1 . charAt ( 0 ) ) ) { s1 . setCharAt ( 0 , Character . toUpperCase ( s1 . charAt ( 0 ) ) ) ; } for ( int j = 1 ; j < s1 . length ( ) ; j ++ ) { if ( Character . isUpperCase ( s1 . charAt ( j ) ) ) { s1 . setCharAt ( j , Character . toLowerCase ( s1 . charAt ( j ) ) ) ; } } return s1 . toString ( ) ; }
Capitalizes the first letter and lower - cases every consecutive letter .