I am writing a code that takes a string array and filters out certain contents that contain a certain letter. For example, for the array that I have, I want to filter out all the contents that contain the letter "b" and remove them out of the array without creating a new array (removes from the existing array). I am currently using the indexOf method and it is giving me problems. It gives me an error saying that int cannot be converted into string. I am not sure what the probelm is with that.
public class Main {
public static void main(String[] args) {
String [] arr = {"abc","bcd", "cad", "aaa"};
for(int i = 0; i < arr.length; i++){
for(int j = 0; j < arr[i].length(); j++){
String index = arr[i].indexOf(j, j + 1);
if(index == "b"){
arr[i] = "";
}
}
}
for(int i = 0; i < arr.length; i++){
System.out.println(arr[i]);
}
}
}