Browse by Topic
Popular
Popular Posts
Latest
Latest Java Posts
Java Clone Method: How to Use It Correctly
Learn how the java clone method works, why shallow copies often fail, and how to implement deep copying correctly or choose safer alternatives like copy constructors.
Java toString Override: Implementation and Pitfalls
Override toString in Java to produce clear, readable object descriptions. Learn null-safe formatting, performance tradeoffs, records, Lombok, and common mistakes to avoid.
Java equals vs ==: Reference vs Value Equality
Understand the difference between == and equals() in Java, how to override equals() correctly, and when to use each comparison for reliable code.
Java equals hashCode Contract: Rules and Implementation
Java classes that override equals() must also override hashCode() to satisfy the equals-hashCode contract. This article explains why HashMap and HashSet depend on that contract, how to implement both methods, and common pitfalls to avoid.
Understanding the Java hashCode Method
How the Java hashCode method works, why it must align with equals, and how to implement it correctly for hash-based collections.
Java equals Method: Contract, Implementation, and Pitfalls
Learn how to correctly override the Java equals() method, understand the equals and hashCode contract, and avoid common pitfalls that break collections.
Java Object finalize: Why It's Deprecated and What to Use
Learn why java object finalize is deprecated, how the JVM invokes it, and why Cleaner and try-with-resources are safer for resource cleanup.
Java Object Cloning: Shallow vs Deep Copy
Understand Java object cloning: shallow vs deep copy, implementing Cloneable correctly, common pitfalls, and practical alternatives.
Java Object getClass: Runtime Type Inspection
Learn how to use Java's Object.getClass() to inspect runtime types, compare classes, and work with reflection while avoiding common pitfalls.
Java Object.toString(): Overriding Default Behavior
Learn how Java's Object.toString() works by default, how to override it for readable output, and how records, null handling, and performance affect the result.