Page 1 of 1

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

Posted: Thu Sep 09, 2021 2:22 pm
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] .
"

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

Posted: Thu Sep 09, 2021 10:28 pm
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 2609 times

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

Posted: Fri Sep 10, 2021 1:43 am
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.

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

Posted: Fri Sep 10, 2021 1:51 am
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.