Write a method / Progrram which will remove any given character from a String.

Write a method / Progrram which will remove any given character from a String?



import java.util.*;


public class  RemoveCharFromString
{
 public static void main(String[] args) 
 {
        System.out.println("Enter String ");
  Scanner scan=new Scanner(System.in);
  String str=scan.nextLine();

         System.out.println("Enter Character to Remove From String ");
  Character c=scan.findInLine(".").charAt(0);
  
  removeCharFromString(str,c);
 }

 public static void removeCharFromString(String str , char c )
 {
 
   int len=str.length();
   int indexArray[]=new int[10];
   int count=0;
 if( str==null)
  System.out.println(" you have not entered String ");
 
 else 
  {
 
       for(int i=0; i < len ; i++ )
   {
    
    if (str.charAt(i)!=c)
    {
  indexArray[count]=i;
  count++;
    }
   
     }
    for(int j : indexArray)
    {
                if(str.charAt(j)==c)
           break;
      System.out.print(str.charAt(j));
  
   
             }
         }
 }
}



OUTPUT :