String oldStr = "helloKitty";
byte[] items = oldStr.getBytes();
items[0] = (byte)((char)items[0] - ( 'a' - 'A'));
String newStr = new String(items);
System.out.println("字符串" + oldStr + "首字母大写后,---》 " + newStr);//字符串helloKitty首字母大写后,---》 HelloKitty
本文介绍了一种使用Java将字符串首字母转换为大写的方法。通过获取字符串的字节数组并调整首字符的ASCII值来实现。最终输出转换后的字符串。
1046

被折叠的 条评论
为什么被折叠?



