Here you can find the source of capitalizeFirstLetter(final CharSequence chars)
Parameter | Description |
---|---|
chars | chars to be processed |
static CharSequence capitalizeFirstLetter(final CharSequence chars)
//package com.java2s; //License from project: Apache License public class Main { /**/*from ww w.j a v a 2 s . c o m*/ * Capitalize the first letter of given {@link CharSequence}. * If the first letter is already capitalized, the char sequence is returned directly. * * @param chars chars to be processed * @return char sequence with first letter capitalized */ static CharSequence capitalizeFirstLetter(final CharSequence chars) { final char first = chars.charAt(0); if (Character.isUpperCase(first)) { return chars; } else { CharSequence following = chars.subSequence(1, chars.length()); return String.valueOf(Character.toUpperCase(first)) + following; } } }