java.util · java.base · since Java 1.7
Objects
public final class ObjectsNull-safe static helpers: equality, hashing, null checks with messages. requireNonNull at method entry is idiomatic precondition checking (EJ 49).
Key methods
static boolean equals(Object a, Object b) | Null-safe equals — true if both null. |
static int hash(Object... values) | Composite hash for hashCode() implementations (boxes varargs — fine outside hot paths). |
static <T> T requireNonNull(T obj, String message) | Throw NPE with context if null — fail fast at the boundary. |
static <T> T requireNonNullElse(T obj, T default) | Null-coalescing. |
static String toString(Object o, String default) | Null-safe toString. |