Question: I need help with this Java question. Please provide the final code and output if possible. Part 3: Using Iterables forEach method, Collections removeIf method,

I need help with this Java question. Please provide the final code and output if possible.

Part 3: Using Iterables forEach method, Collections removeIf method, and Lists replaceAll method

For the following methods, each method body should contain exactly one statement, and that statement should invoke one of the following methods: forEach, removeIf, replaceAll.

1.) public static void removeOdd(List list): Removes every odd integer from the list, and keeps the rest in the list.

2.) public static void removeEvenLength(List list): Removes every String of even length from the list, and keeps the rest in the list.

3.) public static void addStars(List list): Replaces every String in the list with a new String that is like the old String but with a star (asterisk) at the beginning and end of the String. For example, if originally strings represents the list [hello, world], then after we invoke addStars(strings), strings should represent the list [*hello*, *world*].

4.) public static void multiplyEach(List list, int factor): Replaces every integer in the list with the result of multiplying the integer with the given factor.

5.) public static void printEach(List list, int n): For each element of the list, prints the element n times on a single line. For example, if strings represents the list [Hello, World], then printEach(strings, 3) should print the following:

HelloHelloHello

WorldWorldWorld

Hint: see the repeat method of the String class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!