Here you can find the source of capitalizeFirstLetter(String str)
Parameter | Description |
---|---|
str | will be used in capitaling operation. |
public static String capitalizeFirstLetter(String str)
//package com.java2s; //License from project: Open Source License public class Main { /**//from www .jav a 2s .c o m * Makes the first letter uppercase of the given String. * * @param str will be used in capitaling operation. * @return capitalized state of the given param. */ public static String capitalizeFirstLetter(String str) { if (str == null || str.length() == 0) { return str; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(Character.toTitleCase(str.charAt(0))); if (str.length() > 1) { stringBuilder.append(str.substring(1)); } return stringBuilder.toString(); } }