Java

Java

Made by DeepSource

Primitive values don't need to be compared with Object.equals() JAVA-W1080

Anti-pattern
Major
Autofix

Comparing two primitive values with Objects.equals() can be inefficient, since both primitives will have to be boxed before being compared.

Bad Practice

int someInt = ...;

if (Objects.equals(someInt, 3)) { // unnecessary
    // ...
}

Recommended

Use the == operator instead.

if (someInt == 3) {
    // ...
}

References