|
@@ -15,7 +15,9 @@ public class StringParser
|
15
|
15
|
*/
|
16
|
16
|
public static String upperCaseString(String s)
|
17
|
17
|
{
|
18
|
|
- return null;
|
|
18
|
+ String newVar = new String(s);
|
|
19
|
+
|
|
20
|
+ return newVar.toUpperCase();
|
19
|
21
|
}
|
20
|
22
|
|
21
|
23
|
/**
|
|
@@ -26,7 +28,8 @@ public class StringParser
|
26
|
28
|
* @return String
|
27
|
29
|
*/
|
28
|
30
|
public static String lowerCaseString(String s) {
|
29
|
|
- return null;
|
|
31
|
+ String newVar = s.toLowerCase();
|
|
32
|
+ return newVar;
|
30
|
33
|
}
|
31
|
34
|
|
32
|
35
|
/**
|
|
@@ -37,7 +40,9 @@ public class StringParser
|
37
|
40
|
* @return String
|
38
|
41
|
*/
|
39
|
42
|
public static Character getFirstCharacter(String s) {
|
40
|
|
- return null;
|
|
43
|
+ char newVar = s.charAt(0);
|
|
44
|
+ return newVar;
|
|
45
|
+
|
41
|
46
|
}
|
42
|
47
|
|
43
|
48
|
/**
|
|
@@ -49,7 +54,9 @@ public class StringParser
|
49
|
54
|
* @return String
|
50
|
55
|
*/
|
51
|
56
|
public static Character getNthCharacter(String s, Integer n) {
|
52
|
|
- return null;
|
|
57
|
+ char newVar = s.charAt(n);
|
|
58
|
+ return newVar;
|
|
59
|
+
|
53
|
60
|
}
|
54
|
61
|
|
55
|
62
|
/**
|
|
@@ -60,7 +67,10 @@ public class StringParser
|
60
|
67
|
* @return String
|
61
|
68
|
*/
|
62
|
69
|
public static String upperCaseFirstCharacter(String s) {
|
63
|
|
- return null;
|
|
70
|
+ String newVar = s.substring(0, 1).toUpperCase() + s.substring(1);
|
|
71
|
+
|
|
72
|
+ return newVar;
|
|
73
|
+
|
64
|
74
|
}
|
65
|
75
|
|
66
|
76
|
/**
|
|
@@ -72,7 +82,14 @@ public class StringParser
|
72
|
82
|
* @return String
|
73
|
83
|
*/
|
74
|
84
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
85
|
+ String stringLc = s.toLowerCase();
|
|
86
|
+ String[] stringArray = stringLc.split(" ");
|
|
87
|
+ String finalString = "";
|
|
88
|
+ for(int i = 0; i<stringArray.length; i++){
|
|
89
|
+ finalString += stringArray[i].substring(0,1).toUpperCase();
|
|
90
|
+ finalString += stringArray[i].substring(1);
|
|
91
|
+ }
|
|
92
|
+ return finalString;
|
76
|
93
|
}
|
77
|
94
|
|
78
|
95
|
/**
|
|
@@ -84,7 +101,8 @@ public class StringParser
|
84
|
101
|
* @return String
|
85
|
102
|
*/
|
86
|
103
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
104
|
+ String snakeCase = s.replaceAll(" ","_").toLowerCase();
|
|
105
|
+ return snakeCase;
|
88
|
106
|
}
|
89
|
107
|
|
90
|
108
|
/**
|
|
@@ -95,7 +113,9 @@ public class StringParser
|
95
|
113
|
* @return String
|
96
|
114
|
*/
|
97
|
115
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
116
|
+ int returnedVar = s.length();
|
|
117
|
+ return returnedVar;
|
|
118
|
+
|
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
|
+ return s1.equals(s2);
|
|
133
|
+
|
113
|
134
|
}
|
114
|
135
|
|
115
|
136
|
/**
|
|
@@ -123,6 +144,6 @@ 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);
|
127
|
148
|
}
|
128
|
|
-}
|
|
149
|
+}
|