Browse by Topic

Popular

Latest

Latest Java Posts

Diagram illustrating the Java Integer cache range from -128 to 127 and how values outside the range are not cached.
Java

Java Integer Cache: How It Works and Pitfalls

Learn how Java's Integer cache works, why it affects == comparisons, and how to avoid common pitfalls.

autoboxingInteger cachereference equalityJava performance
Illustration showing two Integer objects with the same value compared with == and .equals(), highlighting reference versus value comparison.
Java

Java Integer == vs equals: What Actually Happens

java integer == vs equals: Why == on Integer objects gives inconsistent results, how the -128 to 127 cache works, and when .equals() is the correct comparison method.

JavaInteger comparisonAutoboxingObject equality
An illustration showing two equal Java objects mapping into the same hash bucket inside a HashMap.
Java

Java hashCode Override: Contract and Pitfalls

How to correctly override hashCode() in Java, satisfy the equals/hashCode contract, and avoid common HashMap and HashSet bugs.

hashCodeequalsHashMapJava collections
Two Java objects compared for equality on a balanced scale, representing the equals contract and hashCode consistency.
Java

Java equals Method Override: Contract and Pitfalls

A practical guide to overriding equals() in Java: the equals contract, hashCode consistency, inheritance pitfalls, and field comparison rules.

equals contracthashCodeJava collectionsinheritance
Diagram comparing two Java objects with == and equals(), showing reference vs value comparison
Java

Java Equality: Understanding == vs equals()

Learn how Java equality works: the difference between == and equals(), overriding equals and hashCode, and common pitfalls.

javaequalityequalshashcode
Illustration of a Java reference variable being redirected from one object to another, with a ghost arrow showing the previous target.
Java

Understanding Java Reference Reassignment

Learn how Java reference reassignment changes which object a variable points to, how it differs from mutation, and how final, method parameters, and volatile fields affect it.

java referencesobject mutationfinal keywordpass-by-value
Diagram showing a primitive value copied into a method frame versus an object reference copied while both references share the same heap object
Java

Java Primitive vs Object Parameters: How Passing Works

Java is strictly pass-by-value. See how primitive parameters copy values, object parameters copy references, and why reassignment never changes the caller's variable.

JavaMethod ParametersPass by ValuePrimitive Types
Diagram showing a Java method call copying a object reference value into a parameter, illustrating pass-by-value behavior.
Java

Why Java Is Pass by Value: Understanding References

Understand why Java is pass by value, even for objects. See how references are copied and how to design methods that actually change objects.

Javapass by valuereferencesmethod arguments
Diagram showing two references pointing to the same object in Java memory, illustrating pass by value.
Java

Java Object Reference Pass by Value: How It Works

Understand how Java passes object references by value, why reassigning a parameter doesn't affect the caller, and how to design methods that mutate or replace objects safely.

JavaPass by ValueObject ReferencesMethod Parameters
Diagram showing early binding at compile time and late binding at runtime for Java method dispatch.
Java

Java Early Binding vs Late Binding Explained

Understand the difference between early and late binding in Java: compile-time resolution for overloaded, static, private, and final methods, and runtime dispatch for overridden methods that enable polymorphism.

JavaPolymorphismMethod DispatchJVM