Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions