-
Notifications
You must be signed in to change notification settings - Fork 0
/
StringManipulator.java
32 lines (32 loc) · 1.12 KB
/
StringManipulator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class StringManipulator {
/*given two strings.
if strings have white space, eliminate them.
once white space characters have been eliminated, concat the strings
with no spaces
for char i = 0, i <
*/
public String trimAndConcat(String string1, String string2) {
String newString = string1.trim() + string2.trim();
return newString;
}
public Integer getIndexOrNull(String string, char character) {
int character_position = string.indexOf(character);
if(character_position == -1) {
return null;
}else{
return character_position;
}
}
public Integer getIndexOrNull2(String stringOne, String stringTwo) {
int character_position = stringOne.indexOf(stringTwo);
if(character_position == -1) {
return null;
}else{
return character_position;
}
}
public String concatSubstring(String string1, int int1, int int2, String string2) {
String newString = string1.substring(int1,int2) + string2;
return newString;
}
}