import java.io.*;
import java.util.*;
public class Replacer{
Scanner scan=new Scanner(System.in);
String string, replacing, replaceWith;
public void input(){
try{
System.out.println("Enter any String: ");
string=scan.nextLine();
System.out.println("Enter any String or Character you want to replace: ");
replacing=scan.nextLine();
System.out.println("Enter to which you want to Replace with: ");
replaceWith=scan.nextLine();
}
catch(Exception e){
System.out.println("Error Code: "+e);
System.exit(0);
}
}
public void compute(){
System.out.println("After Replacing \""+replacing+"\" with \""+replaceWith+"\"\nString: "+(string.replace(replacing, replaceWith)));
}
public static void main(String[] args){
Replacer obj=new Replacer();
obj.input();
obj.compute();
}
}
import java.util.*;
public class Replacer{
Scanner scan=new Scanner(System.in);
String string, replacing, replaceWith;
public void input(){
try{
System.out.println("Enter any String: ");
string=scan.nextLine();
System.out.println("Enter any String or Character you want to replace: ");
replacing=scan.nextLine();
System.out.println("Enter to which you want to Replace with: ");
replaceWith=scan.nextLine();
}
catch(Exception e){
System.out.println("Error Code: "+e);
System.exit(0);
}
}
public void compute(){
System.out.println("After Replacing \""+replacing+"\" with \""+replaceWith+"\"\nString: "+(string.replace(replacing, replaceWith)));
}
public static void main(String[] args){
Replacer obj=new Replacer();
obj.input();
obj.compute();
}
}
Comments