I wrote simple program that deletes letter or word from text. Everything works perfectly, but I can't write " " [space] in console. When I do that it does nothing. What should I write into console to tell it that I want to delete space from text?
import java.io.*;
import java.util.*;
public class StringDelete {
public static void main(String args[]) {
String x = "bla bla bla";
System.out.println(x);
System.out.println("What do you want to delete?");
Scanner sc = new Scanner(System.in);
String fr = sc.next();
int po = 0;
int le = x.length();
int i = 0;
do {
po = x.substring(i).indexOf(fr);
if (po != -1) {
x = x.substring(0, po+i) + x.substring(po+i + 1);
}
i += po;
}while(i<le&&po!=-1);
System.out.println(x);
}
}