[HD Pg 0, Sec. 14.1.5 - the-removeif-method]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Ancuta_CIRLAN
Posts: 2
Joined: Thu Sep 09, 2021 2:13 pm
Contact:

[HD Pg 0, Sec. 14.1.5 - the-removeif-method]

Post by Ancuta_CIRLAN »

The example in this section gives "UnsupportedOperationException" because lists created with List.Of are unchangeable. Methods such as add or remove cannot be applied. The book says that the display will be [1,3,5].


Example from the book.

"
List<Integer> iList = List.of(1, 2, 3, 4, 5, 6);
Predicate<Integer> p = x->x%2==0;
iList.removeIf(p);
System.out.println(iList);


The above code prints [1, 3, 5] .
"

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 0, Sec. 14.1.5 - the-removeif-method]

Post by admin »

Which build/version of the book are you seeing this in?
In "Wednesday 21 st October, 2020" Build 2.4, I see a new ArrayList in there. See attached screenshot.
test.png
test.png (81.3 KiB) Viewed 2367 times
If you like our products and services, please help us by posting your review here.

Ancuta_CIRLAN
Posts: 2
Joined: Thu Sep 09, 2021 2:13 pm
Contact:

Re: [HD Pg 0, Sec. 14.1.5 - the-removeif-method]

Post by Ancuta_CIRLAN »

Oh...I'm sorry. It's about 18th Sep 2019 Build 1.7. I did't know it was a new book.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 0, Sec. 14.1.5 - the-removeif-method]

Post by admin »

No, it is the same book but we try to make best use of the On Demand Publishing model to apply corrections as soon as possible.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 35 guests