-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringManipulationTest.java
More file actions
29 lines (23 loc) · 1.04 KB
/
StringManipulationTest.java
File metadata and controls
29 lines (23 loc) · 1.04 KB
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
public class StringManipulationTest {
public static void main(String[] args) {
StringManipulation manipulator = new StringManipulation();
String str = manipulator.trimAndConcat(" Hello ", " World ");
System.out.println(str); // HelloWorld
char letter = 'o';
Integer a = manipulator.getIndexOrNull("Coding", letter);
Integer b = manipulator.getIndexOrNull("Hello World", letter);
Integer c = manipulator.getIndexOrNull("Hi", letter);
System.out.println(a); // 1
System.out.println(b); // 4
System.out.println(c); // null
String word = "Hello";
String subString = "llo";
String notSubString = "world";
Integer x = manipulator.getIndexOrNull(word, subString);
Integer y = manipulator.getIndexOrNull(word, notSubString);
System.out.println(x); // 2
System.out.println(y); // null
String word2 = manipulator.concatSubstring("Hello", 1, 2, "world");
System.out.println(word2); // eworld
}
}