709. 转换成小写字母

题目链接:https://leetcode.cn/problems/to-lower-case/description/

ascii码应用

Java

1
2
3
4
5
6
7
8
9
10
11
class Solution {
public String toLowerCase(String s) {
char[] arr = s.toCharArray();
for (int i = 0; i < arr.length; i++) {
if (arr[i] >= 'A' && arr[i] <= 'Z') {
arr[i] = (char) (arr[i] + 32);
}
}
return new String(arr);
}
}

709. 转换成小写字母
https://pisces34.github.io/2025/03/28/leetcode/709/
发布于
2025年3月28日
许可协议