OneCompiler

You will need to write a program that will remove all occurrences of the second string from the first string.

161


public class StringRemove {

	static void remove(String str, String word){ 
		
         String msg[] = str.split(" ");
        String new_str = "";
 
        for (String words : msg) {     
                                       
            if (!words.equals(word)) {                          
             new_str += words + " ";  
            }
        }
        System.out.print(new_str);     
    }
    public static void main(String[] args){
        String str = " It is a long established fact that a reader will be "
        		+ '\n'+ " distracted by the readable content of a page when looking"
        		+ '\n'+ " at its layout. The point of using Lorem Ipsum is that it"
        		+ '\n'+ " has a more-or-less normal distribution of letters, as"
        		+ '\n'+ " opposed to using 'Content here, content here', making it "
        		+ '\n'+ " look like readable English. Many desktop publishing "
        		+ '\n'+ " packages and web page editors now use Lorem Ipsum as their"
        		+ '\n'+ " default model text, and a search for 'lorem ipsum' will "
        		+ '\n'+ " uncover many web sites still in their infancy. Various "
        		+ '\n'+ " versions have evolved over the years, sometimes by "
        		+ '\n'+ " accident, sometimes on purpose (injected humour and the like)."; 
                                                    
        String word = "is";                                                                          
        remove(str, word);
    }
}