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)); } }
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)); } }
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 19RQ
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
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
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.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT