The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".
The following errata were submitted by our customers and approved as valid errors by the author or editor.
Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update
Version |
Location |
Description |
Submitted By |
Date submitted |
Date corrected |
|
Page Chapter 2: Functional Java
throughout the chapter |
Throughout Chapter 2 "Functional Java" the `java.util.function` package is incorrectly referred to as `java.util.functional`.
Note from the Author or Editor: Thanks!
This is already fixed in a later version.
|
Matthew Janssen |
Oct 26, 2022 |
May 16, 2023 |
|
Page Chapter 3: Immutability
Sub-section: Immutable Collections |
"Also, they’re only shallowly immutable, meaning that you can add or remove any elements, ..." should instead be "... you can't add or remove any elements ..."
Note from the Author or Editor: Thanks!
This is already fixed in a later version.
|
Naufal B |
Oct 31, 2022 |
May 16, 2023 |
|
Page Immutable Collections
https://learning.oreilly.com/library/view/a-functional-approach/9781098109912/ch03.html#:-:text=Instead%20of%20being,to%20the%20elements |
unmodifiableList should be List.copyOf
Something like:
@Test
public void CopyOfTest(){
List<String> modifiable = new ArrayList<>();
modifiable.add("blue");
modifiable.add("red");
List<String> unmodifiable = List.copyOf(modifiable);
// throws UnsupportedOperationException
// unmodifiable.clear();
// throws UnsupportedOperationException
// unmodifiable.add("green");
assertThat(unmodifiable.size(), equalTo(2));
modifiable.add("green");
assertThat(modifiable.size(), equalTo(3)); // hmm - do whatever with the original. Does not bother us
assertThat(unmodifiable.size(), equalTo(2)); // That's better
}
You're welcome :D
Note from the Author or Editor: Thanks!
This is already fixed in a later version.
|
Volker |
Jan 06, 2023 |
May 16, 2023 |
|
Page 41
2nd paragraph |
The second paragraph of page 41 says
The Consumer<T> interface is similar to the Java 5+ Callable<V> found in the java.util.concurrent package, except the latter throws a checked Exception.
This is wrong since Consumer<T> has a SAM with signature
void accept(T t)
while Callable<V> has a SAM with signature
V call() throws Exception
Consumer accepts an input while Callable does not. I think the paragraph is meant for the next section which is about Suppliers. The following paragraph makes sense.
The Supplier<T> interface is similar to the Java 5+ Callable<V> found in the java.util.concurrent package, except the latter throws a checked Exception.
Note from the Author or Editor: You're right with your description of the error, the paragraph in question of Consumer<T> is supposed to belong to Supplier<T>.
|
Jorick Caberio |
Jul 01, 2023 |
Feb 02, 2024 |
|
Page 43
Code sample |
Following snippet of code has a compilation error. Parameter V should not have a comma before variable name v:
@FunctionalInterface
public interface TriFunction<T, U, V, R> {
R accept(T t, U u, V, v);
}
Should be corrected as:
@FunctionalInterface
public interface TriFunction<T, U, V, R> {
R accept(T t, U u, V v);
}
I have created a pull request for the same.
Note from the Author or Editor: That's correct, the comma is superfluous
|
Praveen A Kulkarni |
Nov 21, 2023 |
Feb 02, 2024 |
|
Page 250
Example 10-2 |
The type parameter in the book is U but it should be R
@Override
default R apply(T t) {
try {
return applyThrows(t);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Note from the Author or Editor: The error description is correct, thanks for submitting the errata.
The method signature must match the generic types used in the interface declaration, so the SAM should return R instead of the (non-existent) U.
The code repository, however, uses U throughout.
It doesn't matter which letter is actually used as long as it's consistent.
Still, R might be easier to identify as "returned typed."
|
Jorick Caberio |
Aug 23, 2023 |
Feb 02, 2024 |