Tagged articles
27 articles
Page 1 of 1
DevOps Coach
DevOps Coach
Dec 27, 2025 · Fundamentals

Why Does Integer == Fail for 128? Unveiling Java’s Autoboxing Cache

The article explains why comparing two Integer objects with `==` returns true for values within -128 to 127 but false for larger numbers, detailing Java’s integer cache, reference vs. value equality, and the correct use of `.equals()` to avoid subtle bugs.

AutoboxingInteger cacheJava
0 likes · 6 min read
Why Does Integer == Fail for 128? Unveiling Java’s Autoboxing Cache
Su San Talks Tech
Su San Talks Tech
Oct 3, 2024 · Backend Development

Master Java’s Syntactic Sugar: 10 Features That Simplify Your Code

This article explains what syntactic sugar is, outlines its benefits such as readability, reduced boilerplate, and lower error rates, and then showcases ten concrete Java syntactic‑sugar features—including autoboxing, enhanced for‑loops, generics, varargs, try‑with‑resources, lambdas, method references, string concatenation, switch expressions, and type inference—complete with code examples.

AutoboxingBackend DevelopmentCode Simplification
0 likes · 7 min read
Master Java’s Syntactic Sugar: 10 Features That Simplify Your Code
DaTaobao Tech
DaTaobao Tech
Aug 23, 2024 · Fundamentals

Common Java Pitfalls and Their Solutions

The article outlines frequent Java pitfalls—including BigDecimal precision loss, immutable lists from Arrays.asList, double division by zero returning Infinity, null values in switch statements, stream filters mutating original objects, and autoboxing nulls causing NullPointerExceptions—and provides clear explanations and practical fixes to enhance code reliability.

Arrays.asListAutoboxingBigDecimal
0 likes · 5 min read
Common Java Pitfalls and Their Solutions
IT Services Circle
IT Services Circle
Jul 16, 2022 · Fundamentals

Common Java Pitfalls: Equality, Objects.equals, BigDecimal, Streams, Autoboxing, and String Replacement

This article explains six frequent Java pitfalls—including misuse of the == operator with Integer, subtle bugs in Objects.equals, precision loss with BigDecimal constructors, reference sharing in Stream.filter, NullPointerExceptions from autounboxing, and differences between replace, replaceAll, and replaceFirst—providing code examples and best‑practice recommendations.

AutoboxingBigDecimalJava
0 likes · 12 min read
Common Java Pitfalls: Equality, Objects.equals, BigDecimal, Streams, Autoboxing, and String Replacement
Su San Talks Tech
Su San Talks Tech
Jul 15, 2022 · Fundamentals

6 Common Java Pitfalls Every Developer Should Avoid

This article walks Java developers through six frequent pitfalls—including misuse of the == operator, subtle bugs in Objects.equals, precision issues with BigDecimal, unexpected Stream filter behavior, autoboxing/unboxing surprises, and string replace quirks—offering clear explanations, code examples, and best‑practice solutions to help avoid costly bugs.

AutoboxingBigDecimalJava
0 likes · 13 min read
6 Common Java Pitfalls Every Developer Should Avoid
IT Xianyu
IT Xianyu
Jan 24, 2022 · Fundamentals

Why does Java evaluate 1000==1000 as false while 100==100 evaluates to true?

The article explains that Java's Integer caching for values between -128 and 127 causes small integer objects to be shared, making == true for 100, whereas larger integers like 1000 are distinct objects, so == returns false, and it demonstrates this behavior with code and reflection examples.

AutoboxingJavaReferenceEquality
0 likes · 4 min read
Why does Java evaluate 1000==1000 as false while 100==100 evaluates to true?
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.

AutoboxingJavaReference Equality
0 likes · 5 min read
Understanding Java Integer Caching: Why 1000 == 1000 Is False but 100 == 100 Is True
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Dec 29, 2020 · Fundamentals

Understanding Java Syntactic Sugar: Generics, Autoboxing, Enums, Inner Classes, Varargs and More

This article explains the concept of syntactic sugar in Java, covering generics, autoboxing/unboxing, enums, inner classes, variable‑length arguments, enhanced for‑loops, switch on strings, conditional compilation, assertions, try‑with‑resources, and string concatenation, with code examples and byte‑code analysis.

AutoboxingEnumsGenerics
0 likes · 17 min read
Understanding Java Syntactic Sugar: Generics, Autoboxing, Enums, Inner Classes, Varargs and More
Programmer DD
Programmer DD
Sep 16, 2020 · Backend Development

Why Does Integer == Return True for Small Numbers? Uncover Java’s Integer Cache

This article explains why the == operator returns true for small Integer values in Java, detailing the internal IntegerCache mechanism, demonstrating the behavior with code examples, and showing how reflection can manipulate the cache, highlighting both the benefits and potential pitfalls of this optimization.

AutoboxingInteger cacheReference Equality
0 likes · 4 min read
Why Does Integer == Return True for Small Numbers? Uncover Java’s Integer Cache
Java Captain
Java Captain
Dec 12, 2017 · Fundamentals

Understanding Integer and String Comparison in Java

This article explains Java's Integer and String comparison quirks, detailing how autoboxing caches values between -128 and 127, why '==' behaves differently for objects versus primitives, and demonstrates these concepts with clear code examples and explanations.

AutoboxingObject ComparisonString
0 likes · 7 min read
Understanding Integer and String Comparison in Java
Java Backend Technology
Java Backend Technology
Nov 27, 2017 · Fundamentals

Why Swapping Two Integers Fails in Java? Exploring Pass‑by‑Value, Handles, and Integer Caching

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.

AutoboxingJDKReflection
0 likes · 10 min read
Why Swapping Two Integers Fails in Java? Exploring Pass‑by‑Value, Handles, and Integer Caching
Beike Product & Technology
Beike Product & Technology
Aug 15, 2017 · Mobile Development

Optimizing Android Memory Usage by Avoiding Autoboxing in Long Objects

This article discusses memory optimization in Android apps by addressing excessive object allocations caused by autoboxing Long values, leading to performance issues during feed scrolling. The solution involves implementing a custom data structure to reduce memory usage and improve application responsiveness.

Android optimizationAutoboxingData Structures
0 likes · 8 min read
Optimizing Android Memory Usage by Avoiding Autoboxing in Long Objects
Qunar Tech Salon
Qunar Tech Salon
Mar 21, 2015 · Fundamentals

Understanding Null in Java: Causes, Behaviors, and Best Practices

This article explains the role of the null keyword in Java, its default value for reference types, common pitfalls such as NullPointerException caused by autoboxing, improper primitive assignments, instanceof checks, static method calls on null references, and safe handling techniques to write null‑safe code.

AutoboxingJavaNULL
0 likes · 12 min read
Understanding Null in Java: Causes, Behaviors, and Best Practices