Tag

integer caching

0 views collected around this technical thread.

Full-Stack Internet Architecture
Full-Stack Internet Architecture
May 10, 2025 · Fundamentals

Strange Behaviors in Java: Integer Caching, String Comparison, Unary Plus, and Unicode Tricks

This article explains several counter‑intuitive Java behaviors—including integer caching with configurable range, string literal pool versus new objects, the unary plus being a sign rather than an operator, and Unicode escape processing that can make commented code execute—providing code examples and practical insights.

JavaUnicodeinteger caching
0 likes · 5 min read
Strange Behaviors in Java: Integer Caching, String Comparison, Unary Plus, and Unicode Tricks
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Dec 19, 2023 · Backend Development

Why Comparing Integer Objects with == Fails for Values Outside the Cache Range in Java

The article explains a junior developer's intermittent bug when adding a new order status with code 200, showing that Java's Integer cache and the use of == instead of equals cause the status check to fail, and provides the correct solution.

== vs equalsJavabackend
0 likes · 5 min read
Why Comparing Integer Objects with == Fails for Values Outside the Cache Range in Java
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
Python Programming Learning Circle
Python Programming Learning Circle
Aug 2, 2022 · Fundamentals

Understanding Python's Integer Caching and Reference Counting

The article explains how CPython implements integers as variable‑length base‑2³⁰ arrays, pre‑allocates the small‑integer range –5 to 256 as singleton objects for performance, and demonstrates the effect of this caching using the id() function and reference‑count analysis.

CPythonMemory OptimizationPython
0 likes · 5 min read
Understanding Python's Integer Caching and Reference Counting
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
Python Programming Learning Circle
Python Programming Learning Circle
Dec 12, 2020 · Fundamentals

Understanding Python Object Pooling, Integer Caching, and Interning Mechanisms

This article explains why identical integers and short strings may reference the same object in Python, how the small‑integer cache and string interning work, and how compilation units and constant pools affect object identity across interactive sessions and script files.

Compilation UnitConstant PoolObject Pooling
0 likes · 8 min read
Understanding Python Object Pooling, Integer Caching, and Interning Mechanisms
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Nov 10, 2020 · Fundamentals

Understanding Java Integer Caching and the Pitfalls of Using == vs equals

This article explains Java's Integer caching mechanism, why using == on wrapper objects can be misleading outside the -128 to 127 range, shows how to control the cache size with JVM options, and demonstrates bytecode inspection with javap to reveal the underlying valueOf calls.

JVM optionsJavaJavap
0 likes · 5 min read
Understanding Java Integer Caching and the Pitfalls of Using == vs equals
Python Programming Learning Circle
Python Programming Learning Circle
Apr 9, 2020 · Fundamentals

Understanding the Difference Between Python's `is` and `==` Operators and Integer Caching

The article explains how Python's `is` operator checks object identity while `==` checks value equality, illustrates the small‑integer caching mechanism that makes integers from -5 to 256 share the same object, and shows how assignment patterns affect identity results.

Pythonidentityinteger caching
0 likes · 4 min read
Understanding the Difference Between Python's `is` and `==` Operators and Integer Caching
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Mar 11, 2020 · Fundamentals

Understanding Java Integer Caching and Autoboxing: When == Can Mislead

This article explains Java's Integer caching mechanism, why using == to compare wrapper objects can produce unexpected results, how the IntegerCache works, how to adjust its range with JVM options, and demonstrates the behavior through code examples and javap decompilation.

JavaJavapautoboxing
0 likes · 7 min read
Understanding Java Integer Caching and Autoboxing: When == Can Mislead
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Sep 24, 2019 · Fundamentals

Understanding Java Integer Caching and Autoboxing: Interview Questions Explained

This article explains Java's Integer autoboxing and caching mechanism through three interview code examples, detailing why comparisons of certain Integer objects yield true or false, how the IntegerCache works, and how Java's pass‑by‑value semantics affect object references.

Interview QuestionsJavaautoboxing
0 likes · 4 min read
Understanding Java Integer Caching and Autoboxing: Interview Questions Explained