I'm trying to remove every "x" regardless of case only from the first and second index but my program only removes the first index's letter and then loops without removing the second one.
Scanner userIn = new Scanner(System.in);
StringBuilder str = new StringBuilder();
str.append(userIn.nextLine());
for(int i = 0; i<2; i++) {
if((str.charAt(i) == 'x') || (str.charAt(i) == 'X')) {
str = str.deleteCharAt(i);
}
}
System.out.println(str);