How to capitalize first char in a String Java

Capitalize first char

In this post I would like to show you how to put the first letter into upper case in Java:

  1. Example:
    This is the method to do it:

    private String capitalizeFirstLetter(final String line) {
       String result="";
       if( result != null){
            result = Character.toUpperCase(line.charAt(0)) + line.substring(1);
       }
       return result;
    }

Reference link: http://stackoverflow.com/questions/1892765/capitalize-first-char-of-each-word-in-a-string-java

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s