-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution709.java
More file actions
38 lines (35 loc) · 842 Bytes
/
Copy pathSolution709.java
File metadata and controls
38 lines (35 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @Title: Solution709.java——
* @Package EasyCode
* @Description: TODO
* @author msdumin@gmail.com
* @date 2019年3月27日 下午4:33:25
* @version V1.0
*/
package EasyCode;
/**
* @ClassName: Solution709——
* @Description: TODO
* @author msdumin@gmail.com
* @date 2019年3月27日 下午4:33:25
*/
public class Solution709 {
public String toLowerCase(String str) {
if(str == null)
return null;
StringBuilder sb = new StringBuilder();
char[] arr = str.toCharArray();
for (int i = 0; i < arr.length; i++) {
char c = arr[i];
if(c >= 'a' && c <= 'z')
sb.append(c);
else if(c >= 'A' && c <= 'Z'){
c = (char) (c + ('a' - 'A'));
sb.append(c);
}else {
sb.append(c);
}
}
return sb.toString();
}
}