问题描述
- 字符串的第一个字母大写
- 我不知道应该怎么将字符串的第一个字母转换为大写:
rackingSystem.toLowerCase(); // has capitals in every word so first convert all to lower caseStringBuilder rackingSystemSb = new StringBuilder();rackingSystemSb.append(rackingSystem);rackingSystemSb.setCharAt(0 Character.toUpperCase(rackingSystemSb.charAt(0))); rackingSystem = rackingSystemSb.toString();
这段代码好像没有用。
请大虾指点,谢谢。
解决方案
StringBuilder rackingSystemSb = new StringBuilder( rackingSystem.toLowerCase()); rackingSystemSb.setCharAt(0 Character.toUpperCase(rackingSystemSb.charAt(0))); rackingSystem = rackingSystemSb.toString();
时间: 2024-10-30 17:09:56