Day39--返回大写字母的字符串
Day39--返回大写字母的字符串
使用String类的toUpperCase()方法
示例代码如下:
public class Main {
public static void main(String[] args) {
String str = "hello";
String upperCaseStr = str.toUpperCase();
System.out.println(upperCaseStr);
}
}
- 这种方法直接在原始字符串对象上调用
toUpperCase(),它会返回一个新的字符串,新字符串中的所有字符都是大写形式,而原始字符串不会被改变。

浙公网安备 33010602011771号