Here you can find the source of capitalize(final String str)
Parameter | Description |
---|---|
str | the string to capitalize |
public static String capitalize(final String str)
//package com.java2s; public class Main { /**/*from ww w . j a v a2 s .co m*/ * capitalize the first letter of a string * * @param str * the string to capitalize * @return the capitalized version. */ public static String capitalize(final String str) { if (str == null) { return str; } int strLen = str.length(); if (strLen == 0) { return str; } return new StringBuilder(strLen).append(Character.toTitleCase(str.charAt(0))).append(str.substring(1)) .toString(); } }