I wan't to remove Y from X and this compiles, however when I run it in my main method I get an error saying out of bounds. I am unsure what is wrong. any help would be appreciated.
public static String filter(String X, String Y) {
String i = X;
if ((X != null) && (X.length() >0) && (Y != null) &&Y.length() >0 && (i !=null)){
int z = X.indexOf(Y);
i = X.substring(0, z) +X.substring(z + Y.length());
}
return i;
}