OCP
Java SE11 Programmer I Study Guide, Page 201, Penultimate paragraph.
When discussing autoboxing into Integer, an example is given:
We want to remove the element 1 but the statement at
Line 4 actually removes the element at index 1, which is 2, so what remains is 1 instead of 2. To get the desired result, the book recommend that Line 4 be replaced with
numbers.remove(new Integer(1)).
This is one solution, but strictly speaking, Integer(int) has been deprecated since Java 9. So for the sake of rigor, it seems better to use
numbers.remove(Integer.valueOf(1)), I guess?
An online compiler like Techie Delight accepts
new Integer(1) without any problem, while an
IDE like Eclipse will tell you that "The constructor Integer(int) is deprecated since version 9" and provide two quick fixes; one of which is adding @SuppressWarnings "deprecation" to main(). Of course, an IDE also accepts
new Integer(1).