|
@@ -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.charAt(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.charAt(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 first = s.substring(0,1).toUpperCase() + s.substring(1).toLowerCase();
|
|
64
|
+ return first;
|
64
|
65
|
}
|
65
|
66
|
|
66
|
67
|
/**
|
|
@@ -72,7 +73,13 @@ public class StringParser
|
72
|
73
|
* @return String
|
73
|
74
|
*/
|
74
|
75
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
76
|
+ String str = s.toLowerCase();
|
|
77
|
+ String first = str.split(" ") [0];
|
|
78
|
+ String sec = str.split(" ") [1];
|
|
79
|
+ String word1 = first.substring(0,1).toUpperCase() + first.substring(1).toLowerCase();
|
|
80
|
+ String word2 = sec.substring(0,1).toUpperCase() + sec.substring(1).toLowerCase();
|
|
81
|
+ String totalstr = word1 + word2;
|
|
82
|
+ return totalstr;
|
76
|
83
|
}
|
77
|
84
|
|
78
|
85
|
/**
|
|
@@ -84,7 +91,8 @@ public class StringParser
|
84
|
91
|
* @return String
|
85
|
92
|
*/
|
86
|
93
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
94
|
+
|
|
95
|
+ return s.toLowerCase().replace(' ', '_');
|
88
|
96
|
}
|
89
|
97
|
|
90
|
98
|
/**
|
|
@@ -95,7 +103,7 @@ public class StringParser
|
95
|
103
|
* @return String
|
96
|
104
|
*/
|
97
|
105
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
106
|
+ return s.length();
|
99
|
107
|
}
|
100
|
108
|
|
101
|
109
|
/**
|
|
@@ -109,7 +117,8 @@ public class StringParser
|
109
|
117
|
* @return String
|
110
|
118
|
*/
|
111
|
119
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
120
|
+
|
|
121
|
+ return s1.equals(s2);
|
113
|
122
|
}
|
114
|
123
|
|
115
|
124
|
/**
|
|
@@ -123,6 +132,6 @@ public class StringParser
|
123
|
132
|
* @return String
|
124
|
133
|
*/
|
125
|
134
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
135
|
+ return s1.equalsIgnoreCase(s2);
|
127
|
136
|
}
|
128
|
137
|
}
|