8342863: Use pattern matching for instanceof in equals methods of wrapper classes

Reviewed-by: rriggs
This commit is contained in:
Joe Darcy 2024-10-23 18:23:50 +00:00
parent e64f0798be
commit a21c558699
8 changed files with 16 additions and 17 deletions

View file

@ -477,8 +477,8 @@ public final class Byte extends Number implements Comparable<Byte>, Constable {
* {@code false} otherwise.
*/
public boolean equals(Object obj) {
if (obj instanceof Byte) {
return value == ((Byte)obj).byteValue();
if (obj instanceof Byte b) {
return value == b.byteValue();
}
return false;
}