Program to remove a particular character from a sentence

public class Test

{
  public static void main(String[] args)
  {
 
    String test=null;
        char remove = 0;
    System.out.println("Enter the String");
    test = new Scanner(System.in).nextLine();
    System.out.println("Enter the Character to be removed");
    remove=new Scanner(System.in).nextLine().charAt(0);
    StringBuilder newstring =new StringBuilder();
    for (int i = 0; i < test.length(); i++)
{
    if(remove==test.charAt(i))
    {
    continue;
    }
    newstring.append(test.charAt(i));
  }
   System.out.println(newstring);
  }
 
 
}
 
 
  

Post a Comment