|
@@ -15,7 +15,7 @@ public class StringParser
|
15
|
15
|
*/
|
16
|
16
|
public static String upperCaseString(String s)
|
17
|
17
|
{
|
18
|
|
- return null;
|
|
18
|
+ return s.toUpperCase();
|
19
|
19
|
}
|
20
|
20
|
|
21
|
21
|
/**
|
|
@@ -26,7 +26,7 @@ public class StringParser
|
26
|
26
|
* @return String
|
27
|
27
|
*/
|
28
|
28
|
public static String lowerCaseString(String s) {
|
29
|
|
- return null;
|
|
29
|
+ return s.toLowerCase();
|
30
|
30
|
}
|
31
|
31
|
|
32
|
32
|
/**
|
|
@@ -37,7 +37,7 @@ public class StringParser
|
37
|
37
|
* @return String
|
38
|
38
|
*/
|
39
|
39
|
public static Character getFirstCharacter(String s) {
|
40
|
|
- return null;
|
|
40
|
+ return s.toCharArray()[0];
|
41
|
41
|
}
|
42
|
42
|
|
43
|
43
|
/**
|
|
@@ -49,7 +49,7 @@ public class StringParser
|
49
|
49
|
* @return String
|
50
|
50
|
*/
|
51
|
51
|
public static Character getNthCharacter(String s, Integer n) {
|
52
|
|
- return null;
|
|
52
|
+ return s.toCharArray()[n];
|
53
|
53
|
}
|
54
|
54
|
|
55
|
55
|
/**
|
|
@@ -60,7 +60,8 @@ public class StringParser
|
60
|
60
|
* @return String
|
61
|
61
|
*/
|
62
|
62
|
public static String upperCaseFirstCharacter(String s) {
|
63
|
|
- return null;
|
|
63
|
+ String string = s.substring(0, 1).toUpperCase() + s.substring(1);
|
|
64
|
+ return string;
|
64
|
65
|
}
|
65
|
66
|
|
66
|
67
|
/**
|
|
@@ -72,7 +73,21 @@ public class StringParser
|
72
|
73
|
* @return String
|
73
|
74
|
*/
|
74
|
75
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
76
|
+ String[] stringArr = s.split(" ");
|
|
77
|
+ String answer = "";
|
|
78
|
+
|
|
79
|
+ for(int i = 0; i < stringArr.length; i ++)
|
|
80
|
+ {
|
|
81
|
+ String word = stringArr[i];
|
|
82
|
+
|
|
83
|
+ word = word.toLowerCase();
|
|
84
|
+
|
|
85
|
+ word = word.substring(0,1).toUpperCase() + word.substring(1);
|
|
86
|
+ answer += word;
|
|
87
|
+ System.out.println(answer);
|
|
88
|
+ }
|
|
89
|
+
|
|
90
|
+ return answer;
|
76
|
91
|
}
|
77
|
92
|
|
78
|
93
|
/**
|
|
@@ -84,7 +99,21 @@ public class StringParser
|
84
|
99
|
* @return String
|
85
|
100
|
*/
|
86
|
101
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
102
|
+ String[] stringArr = s.split(" ");
|
|
103
|
+ String answer = "";
|
|
104
|
+
|
|
105
|
+ for(int i = 0; i < stringArr.length; i++)
|
|
106
|
+ {
|
|
107
|
+ String word = stringArr[i];
|
|
108
|
+ word = word.toLowerCase();
|
|
109
|
+ if(i + 1 != stringArr.length)
|
|
110
|
+ {
|
|
111
|
+ answer += word + "_";
|
|
112
|
+ } else {
|
|
113
|
+ answer += word;
|
|
114
|
+ }
|
|
115
|
+ }
|
|
116
|
+ return answer;
|
88
|
117
|
}
|
89
|
118
|
|
90
|
119
|
/**
|
|
@@ -95,7 +124,7 @@ public class StringParser
|
95
|
124
|
* @return String
|
96
|
125
|
*/
|
97
|
126
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
127
|
+ return s.toCharArray().length;
|
99
|
128
|
}
|
100
|
129
|
|
101
|
130
|
/**
|
|
@@ -109,7 +138,12 @@ public class StringParser
|
109
|
138
|
* @return String
|
110
|
139
|
*/
|
111
|
140
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
141
|
+ if(s1.equals(s2))
|
|
142
|
+ {
|
|
143
|
+ return true;
|
|
144
|
+ } else {
|
|
145
|
+ return false;
|
|
146
|
+ }
|
113
|
147
|
}
|
114
|
148
|
|
115
|
149
|
/**
|
|
@@ -123,6 +157,11 @@ public class StringParser
|
123
|
157
|
* @return String
|
124
|
158
|
*/
|
125
|
159
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
160
|
+ if(s1.equalsIgnoreCase(s2))
|
|
161
|
+ {
|
|
162
|
+ return true;
|
|
163
|
+ } else {
|
|
164
|
+ return false;
|
|
165
|
+ }
|
127
|
166
|
}
|
128
|
167
|
}
|