|
@@ -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 t = s.substring(0, 1).toUpperCase() + s.substring(1);
|
|
64
|
+ return t;
|
64
|
65
|
}
|
65
|
66
|
|
66
|
67
|
/**
|
|
@@ -72,7 +73,16 @@ public class StringParser
|
72
|
73
|
* @return String
|
73
|
74
|
*/
|
74
|
75
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
76
|
+ //MAKE ALL LOWER CASE
|
|
77
|
+ String lowerCase = s.toLowerCase();
|
|
78
|
+ //SPLIT BETWEEN FIRST WORD AND SECOND WORD
|
|
79
|
+ String first = lowerCase.substring(0,(lowerCase.indexOf(" ")));
|
|
80
|
+ String second = lowerCase.substring((lowerCase.indexOf(" ") + 1),lowerCase.length());
|
|
81
|
+ //CAPITALIZE BOTH WORDS INDEX OF [0]
|
|
82
|
+ String firstCap = first.substring(0, 1).toUpperCase() + first.substring(1,first.length());
|
|
83
|
+ String secondCap = second.substring(0, 1).toUpperCase() + second.substring(1,second.length());
|
|
84
|
+ //COMBINED BOTH WORDS
|
|
85
|
+ return firstCap + secondCap;
|
76
|
86
|
}
|
77
|
87
|
|
78
|
88
|
/**
|
|
@@ -84,7 +94,8 @@ public class StringParser
|
84
|
94
|
* @return String
|
85
|
95
|
*/
|
86
|
96
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
97
|
+ String underscore = s.toLowerCase().replaceAll(" ","_");
|
|
98
|
+ return underscore;
|
88
|
99
|
}
|
89
|
100
|
|
90
|
101
|
/**
|
|
@@ -95,7 +106,7 @@ public class StringParser
|
95
|
106
|
* @return String
|
96
|
107
|
*/
|
97
|
108
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
109
|
+ return s.length();
|
99
|
110
|
}
|
100
|
111
|
|
101
|
112
|
/**
|
|
@@ -109,7 +120,7 @@ public class StringParser
|
109
|
120
|
* @return String
|
110
|
121
|
*/
|
111
|
122
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
123
|
+ return s1.equals(s2);
|
113
|
124
|
}
|
114
|
125
|
|
115
|
126
|
/**
|
|
@@ -123,6 +134,6 @@ public class StringParser
|
123
|
134
|
* @return String
|
124
|
135
|
*/
|
125
|
136
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
137
|
+ return s1.equalsIgnoreCase(s2);
|
127
|
138
|
}
|
128
|
139
|
}
|