Errata

Modern Java Recipes

Errata for Modern Java Recipes

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF Page Page 280
The line after the comparing() method declaration

Text from the book "Let’s start by breaking down the argument to the compare method, whose name is keyExtractor and is of type Function."

It refers to "compare" method. It should be "comparing".

Satishchandra Singh  Jan 11, 2024 
PDF Page Page 280
The last line of the paragraph after the comparing() method declaration

The last line of the paragraph refers to compare() method. It should be comparing() method.

Satishchandra Singh  Jan 12, 2024 
2.2
Example 2-4

The signature of method Logger.info is
Logger.info(Supplier<String> msgSupplier)

The example seems to pass a randomSupplier which is of type DoubleSupplier into it.

Anonymous  Mar 22, 2019 
Printed, ePub Page 9
First paragraph (after example 1-10)

I believe the definition of Comparator<T> abstract method is incorrect. Comparator does not have method compare(String other), even if <T> is String. It would be compare(<T> o1, <T> o2).

Raymond L Naseef  Feb 11, 2019 
31
Example 3-5

long count = Stream.generate(Math::random)
.limit(10)
.forEach(System.out::println)


forEach() return void as it is consumer.

Instead it needed to be updated to this :
Stream<Double> count = Stream.generate(Math::random)
.limit(10);


Note: I could not see the page number hence putting chapter.section -> 3.1(remove point) ->
31.

Pradeep Bhardwaj  Aug 29, 2021 
Printed Page 37
First paragraph

IntStream is split into 2 lines, as if it is two words. That is incorrect.

Raymond L Naseef  Feb 23, 2019 
PDF Page 275
2nd paragraph

The 2nd paragraph on Page 275 reads as below:

"Here, however, we’re taking the items from the list and adding them to a different collection.
That destination collection could be a List<Number>, but it could also be a
List<Object> because the individual Object references can be assigned to a Number."

The last line should be "That destination collection could be a List<Number>, but it could also be a
List<Object> because the individual Number references can be assigned to a Object."

Number references can be assigned to Object references and not vice versa.

Satishchandra Singh  Apr 13, 2022