Tag

Reference Equality

0 views collected around this technical thread.

Architecture Digest
Architecture Digest
Sep 12, 2023 · Fundamentals

Understanding Java Integer Caching and the == Operator

This article explains how Java caches Integer objects in the range -128 to 127, why the == operator behaves differently for small and large integers, and demonstrates how to inspect and manipulate the cache using reflection.

JavaMemory OptimizationReference Equality
0 likes · 4 min read
Understanding Java Integer Caching and the == Operator
Java Captain
Java Captain
Mar 1, 2022 · Fundamentals

Understanding Java Integer Caching and the == Operator

This article explains why comparing Integer objects with == yields false for large values but true for small values due to Java's internal IntegerCache, demonstrates the caching mechanism with code examples, and shows how reflection can manipulate the cache, highlighting memory optimization considerations.

JavaMemory OptimizationReference Equality
0 likes · 4 min read
Understanding Java Integer Caching and the == Operator
Top Architect
Top Architect
Jan 2, 2022 · Backend Development

Understanding Java Integer Caching: Why 1000 == 1000 Is False but 100 == 100 Is True

The article explains that Java's Integer objects use an internal cache for values between -128 and 127, causing equality checks with the == operator to return true for small numbers like 100 but false for larger numbers like 1000, and demonstrates how to inspect and manipulate this cache via reflection.

IntegerJavaReference Equality
0 likes · 5 min read
Understanding Java Integer Caching: Why 1000 == 1000 Is False but 100 == 100 Is True
Java Captain
Java Captain
Jun 6, 2021 · Fundamentals

Understanding the Differences Between a.equals(b) and Objects.equals(a, b) in Java

This article explains how a.equals(b) behaves when a or b is null or an empty string, compares it with Objects.equals, and analyzes the underlying source code to clarify the differences between reference equality (a==b) and logical equality (a.equals(b)) in Java.

JavaLogical EqualityObjects.equals
0 likes · 6 min read
Understanding the Differences Between a.equals(b) and Objects.equals(a, b) in Java