I am trying to make a program using While to remove any letters in the String
.
So the string would be abcXabcXabc
and I would say X
and it would remove it.
I.e abcabcabc
. I have written most of the class but I am stumped on what I would put into my while loop.
class LineCleaner {
private String line;
private char remove;
public LineCleaner(String s, char rem) {
setCleaner(s, rem);
}
public void setCleaner(String s, char rem) {
line = s;
remove = rem
}
public String getCleaned() {
String cleaned = line;
int loc = cleaned.indexOf(remove);
while (/*CONDITION*/) {
// what to do here
}
return cleaned;
}
public String toString() {
return line + " - letter to remove " + remove;
}
}