i have the following piece of code but i could not detect why there is no output when i debug it , the control flow is never goes inside for loop but i cannot figure out why
could anyone please help me ? here is my code
public class DealWithStrings {
ArrayList<String> container = new ArrayList<>();
public void printDuplicate() {
String string = "aaabed";
String[] res = string.split("");
for (int i = 1; i < string.length(); i++) {
if (res[i] == res[i - 1]) {
container.add(res[i]);
}
}
for (String s : container) {
System.out.println(s);
}
}
public static void main(String[] args) {
DealWithStrings d = new DealWithStrings();
d.printDuplicate();
}
}