Hello,
I'm working on a little project.
I need to have program which:
1. reads textline from user (example: A little cat goes to town)
2. a) reads words what user wants to change to 0 (example word cat to 000)
b) one word to one line and if given only Enter it stops reading and moves to 3.
3. finds and replaces those words
So in the end it prints: A little 000 goes to town
Here is my current code. Im really struckeling.
public static void main(String[] args) {
while (true){
System.out.println("Line");
String givenLine = reader.nextLine();
if (givenLine.matches("end")) break;
System.out.println("Words you want to replace");
String givenReplace = reader.nextLine();
StringBuffer sb = new StringBuffer(givenLine);
System.out.println("Original Text : " + sb);
sb.replace(????);
System.out.println("Replaced Text : " + sb);
}
}