capitalize the first letter in string - Android java.lang

Android examples for java.lang:String Case

Description

capitalize the first letter in string

Demo Code

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String capitalize(final String word) {
        if (word.length() > 1) {
            return String.valueOf(word.charAt(0)).toUpperCase()
                    + word.substring(1);
        }//from   w  w w  .java2 s .co m
        return word;
    }

}

Related Tutorials