|
@@ -15,7 +15,8 @@ public class StringParser
|
15
|
15
|
*/
|
16
|
16
|
public static String upperCaseString(String s)
|
17
|
17
|
{
|
18
|
|
- return null;
|
|
18
|
+ String str = s.toUpperCase();
|
|
19
|
+ return str;
|
19
|
20
|
}
|
20
|
21
|
|
21
|
22
|
/**
|
|
@@ -26,7 +27,9 @@ public class StringParser
|
26
|
27
|
* @return String
|
27
|
28
|
*/
|
28
|
29
|
public static String lowerCaseString(String s) {
|
29
|
|
- return null;
|
|
30
|
+ String str = s.toLowerCase();
|
|
31
|
+
|
|
32
|
+ return str;
|
30
|
33
|
}
|
31
|
34
|
|
32
|
35
|
/**
|
|
@@ -37,7 +40,10 @@ public class StringParser
|
37
|
40
|
* @return String
|
38
|
41
|
*/
|
39
|
42
|
public static Character getFirstCharacter(String s) {
|
40
|
|
- return null;
|
|
43
|
+
|
|
44
|
+ char str = s.charAt(0);
|
|
45
|
+
|
|
46
|
+ return str ;
|
41
|
47
|
}
|
42
|
48
|
|
43
|
49
|
/**
|
|
@@ -49,7 +55,8 @@ public class StringParser
|
49
|
55
|
* @return String
|
50
|
56
|
*/
|
51
|
57
|
public static Character getNthCharacter(String s, Integer n) {
|
52
|
|
- return null;
|
|
58
|
+ char str =s.charAt(n);
|
|
59
|
+ return str;
|
53
|
60
|
}
|
54
|
61
|
|
55
|
62
|
/**
|
|
@@ -60,19 +67,29 @@ public class StringParser
|
60
|
67
|
* @return String
|
61
|
68
|
*/
|
62
|
69
|
public static String upperCaseFirstCharacter(String s) {
|
63
|
|
- return null;
|
|
70
|
+ String str= s.substring(0, 1).toUpperCase() + s.substring(1);
|
|
71
|
+ return str;
|
64
|
72
|
}
|
65
|
73
|
|
66
|
74
|
/**
|
67
|
75
|
* Takes a String and returns that string with the first character of each word in it uppercased
|
68
|
76
|
* and then joined.
|
69
|
77
|
* E.G. dog whistle would return DogWhistle. adjuNCT pRoFessOR would return AdjuctProfessor.
|
70
|
|
- *
|
|
78
|
+ *;
|
71
|
79
|
* @param s
|
72
|
80
|
* @return String
|
73
|
81
|
*/
|
74
|
82
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
83
|
+ String str = s.toLowerCase();
|
|
84
|
+
|
|
85
|
+ String x = str. split(" ")[0];
|
|
86
|
+ String y= str.split (" ")[1];
|
|
87
|
+
|
|
88
|
+ String upperCase = x.substring(0, 1).toUpperCase() + x.substring(1).toLowerCase();
|
|
89
|
+ String upperCase1 = y.substring(0, 1).toUpperCase()+y.substring(1).toLowerCase();
|
|
90
|
+ String last = upperCase + upperCase1;
|
|
91
|
+
|
|
92
|
+ return last.trim();
|
76
|
93
|
}
|
77
|
94
|
|
78
|
95
|
/**
|
|
@@ -84,7 +101,10 @@ public class StringParser
|
84
|
101
|
* @return String
|
85
|
102
|
*/
|
86
|
103
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
104
|
+ String str = s.toLowerCase();
|
|
105
|
+ String first= str.replace(" ", "_");
|
|
106
|
+
|
|
107
|
+ return first;
|
88
|
108
|
}
|
89
|
109
|
|
90
|
110
|
/**
|
|
@@ -95,7 +115,7 @@ public class StringParser
|
95
|
115
|
* @return String
|
96
|
116
|
*/
|
97
|
117
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
118
|
+ return s.length();
|
99
|
119
|
}
|
100
|
120
|
|
101
|
121
|
/**
|
|
@@ -109,7 +129,8 @@ public class StringParser
|
109
|
129
|
* @return String
|
110
|
130
|
*/
|
111
|
131
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
132
|
+
|
|
133
|
+ return s1.equals(s2);
|
113
|
134
|
}
|
114
|
135
|
|
115
|
136
|
/**
|
|
@@ -123,6 +144,7 @@ public class StringParser
|
123
|
144
|
* @return String
|
124
|
145
|
*/
|
125
|
146
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
147
|
+ return s1.equalsIgnoreCase(s2);
|
|
148
|
+
|
127
|
149
|
}
|
128
|
150
|
}
|