object-class
7 tutorials tagged “object-class”.
- Object Equality and Hash Codes in JavaDefine when two objects are equal, keep hashCode consistent with it, and see HashSet and HashMap break when the contract is violated.
- Java Finalize Method (Deprecated)Why finalize() was meant for cleanup, why it never worked well, the removal warning in Java 25, and what to use instead: try-with-resources and Cleaner.
- getClass() Method in JavaFind an object's runtime class with getClass(): getName vs getSimpleName, class literals, comparing classes, and how it differs from instanceof.
- Object Class in Javajava.lang.Object is the root of every class. Its 11 methods, what each is for, and why every object can be stored in an Object variable.
- Object Cloning in JavaCopy objects with clone(): the Cloneable marker, overriding clone correctly, shallow vs deep copies with a shared-array bug, and better alternatives.
- Objects Utility Class in Javajava.util.Objects: null-safe equals and hashCode, requireNonNull for fail-fast checks, defaults for null values, and index checks, with examples.
- toString() Method in JavaGive objects a readable text form: the default ClassName@hash output, overriding toString, where Java calls it for you, and printing arrays.