java Create a static method that: is called removeAll returns ArrayList takes two parameters: an ArrayList of Strings called wordList, and a String called targetWord This method should go through every element of wordList and remove every instance of targetWord from the ArrayList. Example:   ArrayList wordList = new ArrayList(Arrays.asList("hi","hey","hi","yo"));   removeAll(wordList,"hi");   wordList: ["hey","yo"]    public static void main(String[] args) {     Scanner in = new Scanner(System.in);     int size = in.nextInt();     String target = in.next();     ArrayList list = new ArrayList<>();     for(int i=0; i < size; i++) {       list.add(in.next());     }     System.out.println(removeAll(list, target));   }       }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question

java

Create a static method that:

  • is called removeAll
  • returns ArrayList<String>
  • takes two parameters: an ArrayList of Strings called wordList, and a String called targetWord

This method should go through every element of wordList and remove every instance of targetWord from the ArrayList.

Example:

 
ArrayList<String> wordList = new ArrayList<String>(Arrays.asList("hi","hey","hi","yo"));
 
removeAll(wordList,"hi");
 
wordList: ["hey","yo"]
 

 public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int size = in.nextInt();
    String target = in.next();
    ArrayList<String> list = new ArrayList<>();
    for(int i=0; i < size; i++) {
      list.add(in.next());
    }

    System.out.println(removeAll(list, target));

  } 


    
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT