remove special character from String

Q ) Remove Special Character from String. 


public class HelloWorld{


     public static void main(String []args){

        

        String file = "Good Morning! Mr. James Potter. Had your breakfast?";

        String remove ="";

        

        for(int i =0 ;i<file.length();i++){

            char a = file.charAt(i);

            if(a=='!' || a== '.' || a=='?'){

            }else{

                remove = ""+ a;

                System.out.print(remove);

            }

        }

       

     }

}

Comments

Popular posts from this blog

Git and Github

bubble short Q1

Java Program to Check Whether the String Consists of Special Characters