I seems that somehow the deprecated (since
Java 9) new Integer(50) made it into the errata instead of Integer.valueOf(50) suggested here.
In the first code example. line 7 should be weights.remove(new Integer(50)); and the sentence about Line 7 in the following paragraph should be removed
Edit: on the same page at the end of "Autoboxing and Unboxing" the depricated Integer constructor is used again.