
Write a program that takes two parameters 1. a word 2. an array of words
It should then remove all instances of the word in the array.
For Example: INPUT
word="ravi" word_array = ["Chethan Bhagat", "Ravi Beligere", "Ravana Kumar", "Megnath Ravichandran", "Superraviman guy"....]
OUTPUT
["Chethan Bhagat", " Beligere", "Ravana Kumar", "Megnath chandran", "Superman guy"....]
NOTE

The given code accepts a word and array of five words which then remove the occurrence of word in those array elements.
import java.util.*;
class RemoveFromArray
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter word: ");
String word=input.nextLine().toLowerCase();
System.out.println("Input array of words: ");
String array[]=new String[5];
String newarray[]=new String[5];
for(int i=0;i<array.length;i++){
array[i]=input.nextLine().toLowerCase();
}
System.out.println("Output array of words: ");
for(int i=0;i<newarray.length;i++){
newarray[i]=array[i].replaceAll(word,"").trim();
System.out.println(newarray[i]);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.