I wrote a text, and i want to change some chars to any other chars which the user will choosing them, I tried and couldn't find the correct answer, so please guide me. the code in the MyTest Class is:
public String replace(String input,char from,char to){
String input2 ="";
String input3="";
this.input=input3;
for(int i=0;i<input.length();i++){
for(int j=0;j<input3.length();j++){
if(input.charAt(i)==input3.charAt(j)){
input2=input3.replace(from, to);
System.out.println(input2);
}
}
}
return input2;
}
And the code in the Main Class:
System.out.println("please enter the new character: ");
char c1 = scan.next().charAt(0);
System.out.println("Please choose the letters that you want to change it which in the text:");
String ltr = scan.next();
obj1.convertChars(ltr, c1);