示例字符串
one thousand only
two hundred
twenty
seven
如何更改字符串的第一个大写字母,而不更改其他任何字母的大小写?
更改后,应该是:
One thousand only
Two hundred
Twenty
Seven
注意:我不想使用apache.平民lang.WordUtils必须这样做.
示例字符串
one thousand only
two hundred
twenty
seven
如何更改字符串的第一个大写字母,而不更改其他任何字母的大小写?
更改后,应该是:
One thousand only
Two hundred
Twenty
Seven
注意:我不想使用apache.平民lang.WordUtils必须这样做.
如果您只想将名为input
的字符串的第一个字母大写,而不想使用睡觉:
String output = input.substring(0, 1).toUpperCase() + input.substring(1);
现在output
人会得到你想要的.在使用此选项之前,请判断input
是否至少包含一个字符,否则会出现异常.