马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.
Example 1:
Input: "Hello"
Output: "hello"
Example 2:
Input: "here"
Output: "here"
Example 3:
Input: "LOVELY"
Output: "lovely"
class Solution {
public String toLowerCase(String str) {
String re = "";
for(int i = 0; i <str.length() ; i++){
if(str.charAt(i) >= 'A' && str.charAt(i)<= 'Z') re = re +(char) ((int)str.charAt(i) + 32);
else re = re + str.charAt(i);
}
return re;
}
}
|