Tagged articles
Integer caching
15 articles · Page 1 of 1
In Java, comparing two Integer objects with == yields false for 1000 but true for 100 because the language caches small integer instances (-128 to 127) via Integer.valueOf, causing both variables to reference the same object only within that range.
AutoboxingInteger cachingJava
0 likes · 4 min read

The article explains why comparing two Integer objects with == yields true for values within -128 to 127 but false for larger values, detailing Java's integer caching, the Flyweight pattern, and the proper use of equals() for value comparison.
AutoboxingFlyweight patternInteger caching
0 likes · 7 min read

This article explains why Python’s is operator can yield False for seemingly identical integers, how integer caching and code‑block reuse affect object identity, common pitfalls with re.sub’s count parameter, the character‑based behavior of lstrip, and why list multiplication creates shared references.
Integer cachingPythonis-operator
0 likes · 8 min read

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 equalsEnumInteger caching
0 likes · 5 min read

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.
Integer cachingJavaMemory Optimization
0 likes · 4 min read

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.
CPythonInteger cachingReference Counting
0 likes · 5 min read

Many interviewees expect the Java expression ‘a == b’ to be false and ‘c == d’ true when using Integer objects, but due to the Integer cache range and JVM settings, both comparisons can actually return true, a nuance explained through source code analysis and cache configuration.
Integer cachingJVMJava
0 likes · 6 min read

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.
Integer cachingJavaMemory Optimization
0 likes · 4 min read

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 PoolInteger caching
0 likes · 8 min read

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.
AutoboxingEquals vs ==Integer caching
0 likes · 5 min read

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.
Integer cachingidentityis-operator
0 likes · 4 min read

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.
AutoboxingEquals vs ==Integer caching
0 likes · 7 min read

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.
AutoboxingInteger cachingInterview questions
0 likes · 4 min read

This article explains why the same integer values can produce different results with the ‘is’ operator in Python, covering small‑integer caching, the general integer object pool, constant pools, and the distinction between whole‑module and line‑by‑line execution modes.
Constant PoolInteger cachinginterpreter
0 likes · 9 min read

This article dissects a Java interview question about swapping two Integer variables, explaining Java's pass‑by‑value semantics, the difference between handle‑based and direct pointer object access, Integer immutability, autoboxing, the IntegerCache mechanism, and how reflection can (or cannot) modify private final fields.
AutoboxingInteger cachingJDK
0 likes · 10 min read
