-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugingPart2.java
More file actions
27 lines (24 loc) · 794 Bytes
/
DebugingPart2.java
File metadata and controls
27 lines (24 loc) · 794 Bytes
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
import java.util.Scanner;
public class DebugingPart2 {
public void findAbc(String input){
int index = input.indexOf("abc");
while (true){
if (index == -1 || index >= input.length() - 3){
break;
}
System.out.println("index before updating: " + index);
String found = input.substring(index + 1, index + 4);
System.out.println(found);
index = input.indexOf("abc", index + 4);
System.out.println("index after updating: " + index);
}
}
public void test(){
//findAbc("abcd");
findAbc("abcdabc");
}
public static void main(String[] args) {
DebugingPart2 debuggingPart2 = new DebugingPart2();
debuggingPart2.test();
}
}