The assignment is to, for example, remove char 'a' from the String "I am Sam am I Sam", this is a bit code I have so far:
public String removeLetters() {
String cleaned=sentence;
StringBuilder builder = new StringBuilder(cleaned);
while(cleaned.indexOf(lookFor) != -1) {
builder.deleteCharAt(cleaned.indexOf(lookFor));
}
return builder.toString();
}
This method returns fine when there's no while loop (though it only removes one char), but when I run it with the while loop I get the OutOfBounds error.