This article explains why Java's Integer and String objects behave differently when compared with ==, covering autoboxing, the Integer cache range, string constant pool behavior, and the effects of unboxing on equality checks.
This article explains Java's String class, covering its automatic import, how to create string objects without the new keyword, concatenation, immutability, common methods like replace, and provides useful API references and code examples for practical use.
This article explains the internal implementation of Java's String class, compares it with StringBuilder and StringBuffer, demonstrates performance differences through benchmark code, and provides common interview questions with detailed answers, helping developers choose the appropriate class for various scenarios.
This article explains how Java strings are defined, how assigning one string variable to another copies the reference, how concatenation creates a new immutable string object, and why mutable alternatives like StringBuilder should be used to avoid excessive garbage collection.
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.
This article explains the concept of immutable objects in Java, using String as a case study, clarifies the difference between object references and objects, examines String’s internal fields across JDK versions, demonstrates how typical mutating methods actually create new instances, and shows how reflection can bypass immutability.
This article explains the default implementations of Java's Object.equals() and Object.hashCode(), the required contracts for overriding them, demonstrates their behavior in the String class, and provides practical guidelines and example code for correctly overriding these methods in custom classes.
This article explains the fundamental differences between JavaScript's exec and match methods, showing which belongs to RegExp or String, how the global "g" flag affects their behavior, and provides practical code examples to help you choose the right one.
This article introduces Redis's five core data structures—String, List, Set, Hash, and Sorted Set—detailing their characteristics, common commands, additional operations, and typical use cases, providing a comprehensive guide for developers working with Redis.
This article explains Java's String object characteristics—immutability, constant pool optimization, and final class—while offering practical performance tips such as avoiding split(), preferring StringBuilder over '+' concatenation, and choosing optimal conversion methods for primitive types.
This article explains Java String's immutability, constant pool optimization, the impact of the final keyword, and practical techniques such as using split alternatives, StringBuilder/StringBuffer, and efficient primitive-to-String conversions to dramatically improve performance.
This article explains how to convert primitive types to strings in Java, discusses why simple concatenation with an empty string is inefficient, compares different splitting implementations, benchmarks various string concatenation methods including String.concat, the '+' operator, and StringBuilder, and recommends using String.valueOf and the OptimizeStringConcat JVM option for better performance.
This article explores several under‑used yet useful Google Guava utilities—including unsigned primitive types, 128‑bit MurmurHash, InternetDomainName parsing, class‑path reflection, and CharMatcher string handling—providing code examples and explanations of how they can improve Java development efficiency.