Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have to write the following method: public boolean removeIf(Predicate filter) - Removes all of the elements of this collection that satisfy the given predicate.

I have to write the following method:

public boolean removeIf(Predicate filter) - Removes all of the elements of this collection that satisfy the given predicate. Returns true if at least one element is removed from the list. Otherwise, the method returns false.

* Use the removeIf method and a lambda expression to remove Person

* objects whos age is less than 30

*/

System.out.println(" Display Person list after remove age < 30: ");

for (Person p : arrP) {

System.out.println(p);

}

MyCollection tmpP = new MyArrayList<>();

tmpP.add(new Person("Pilar", "Ess", 34));

tmpP.add(new Person("Jill", "Z", 30));

arrP.retainAll(tmpP);

System.out.println(" Display Person list after retainAll: ");

for (Person p : arrP) {

System.out.println(p);

I need this method to be added to following MyCollection interface:

public interface MyCollection { public boolean add(E item); public void add(int index,E item); public E get(int index); public E remove(int index); public boolean remove(Object o); public void clear(); public E set(int index, E item); public int size(); public boolean contains(Object o); public boolean isEmpty(); public int indexOf(Object o); }

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_2

Step: 3

blur-text-image_3

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

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

3rd Edition

0760049041, 978-0760049044

More Books

Students also viewed these Databases questions

Question

Q: Please describe your organisations HR department.

Answered: 1 week ago

Question

Be familiar with the five basic ways to manage demand.

Answered: 1 week ago