0
点赞
收藏
分享

微信扫一扫

【坚持每日一题5.30】709. 转换成小写字母

瑾谋 2023-03-23 阅读 69


给你一个字符串 s ,将该字符串中的大写字母转换成相同的小写字母,返回新的字符串。

示例 1:

输入:s = “Hello”
输出:“hello”
示例 2:

输入:s = “here”
输出:“here”
示例 3:

输入:s = “LOVELY”
输出:“lovely”

java代码:

class Solution {
    public String toLowerCase(String str) {
        int i=0;
        int len=str.length();
        char[] chs=str.toCharArray();
     for(;i<len;i++){
            if(chs[i]>='A'&& chs[i]<='Z'){
                chs[i]+=32;
                
            }
                
        }
        return String.valueOf(chs);
        
    }
}


举报

相关推荐

0 条评论