What are the different ways to check if an object is null in Java besides `== null`?

Another great way is using Optional to wrap your object and check if it’s present.

import java.util.Optional;

public boolean checkIfEntityNull(BaseEntity entity) {
    return Optional.ofNullable(entity).isPresent(); // Returns true if not null
}

It makes the code more null-safe and avoids NullPointerException when chaining methods.