-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day23.java
33 lines (24 loc) · 1.01 KB
/
Day23.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
33
import java.util.ArrayList;
import java.util.List;
public class ManualStringSplit {
public static void main(String[] args) {
String inputString = "Hello ,World ,Java,Split,Example";
char delimiter = ',';
List<String> substrings = new ArrayList<>();
StringBuilder currentSubstring = new StringBuilder();
for (char character : inputString.toCharArray()) {
if (character == delimiter) {
substrings.add(currentSubstring.toString());
currentSubstring.setLength(0);
} else {
currentSubstring.append(character);
}
}
substrings.add(currentSubstring.toString());
System.out.println("Original string: " + inputString);
System.out.println("Split into substrings:");
for (String substring : substrings) {
System.out.println(substring);
}
}
}