Tagged articles
26 articles
Page 1 of 1
Lobster Programming
Lobster Programming
Dec 20, 2024 · Fundamentals

Unlocking Java’s Constant Pools: Class, Runtime, and String Explained

This article explains Java’s constant pools, detailing the class constant pool stored in .class files, its transformation into the runtime constant pool during JVM loading, and the specialized string constant pool that optimizes memory usage, including recent changes moving it to heap memory.

Constant PoolJVMMemory Management
0 likes · 3 min read
Unlocking Java’s Constant Pools: Class, Runtime, and String Explained
Lobster Programming
Lobster Programming
Dec 16, 2024 · Fundamentals

How Many Objects Does Java Create for Different String Initializations?

This article explains how Java creates objects for various String assignments—using new String("long"), a literal "long", or concatenated literals "lo" + "ng"—detailing when one or two objects are allocated based on the presence of the literal in the string constant pool.

Constant PoolMemory ManagementObject Creation
0 likes · 3 min read
How Many Objects Does Java Create for Different String Initializations?
Top Architecture Tech Stack
Top Architecture Tech Stack
Oct 16, 2023 · Fundamentals

Understanding JVM Platform Independence and Class File Structure

This article explains how the Java Virtual Machine achieves platform and language independence, details the compilation process from source code to class files, and provides an in‑depth analysis of the class file format, constant pool, bytecode instructions, access flags, and related metadata.

Constant PoolJVMJava Internals
0 likes · 14 min read
Understanding JVM Platform Independence and Class File Structure
Selected Java Interview Questions
Selected Java Interview Questions
Apr 7, 2023 · Backend Development

Understanding Object Creation in Java: How Many Objects Are Created by `String s = new String("xyz")`?

This article explains the evolution of the Java method area, analyzes bytecode generated by `String s = new String("xyz")` and `String s = "xyz"`, and clarifies why the expression creates one or two objects depending on whether the literal already exists in the constant pool.

BackendConstant PoolObject Creation
0 likes · 7 min read
Understanding Object Creation in Java: How Many Objects Are Created by `String s = new String("xyz")`?
Top Architect
Top Architect
Nov 17, 2022 · Fundamentals

Understanding Java String Object Creation and Memory Allocation

This article explains how Java handles string literals and new String objects, detailing the creation of objects in the constant pool and heap, the resulting memory layout, and the outcomes of reference comparisons, while also providing code examples and additional resources.

Constant PoolMemory ManagementObject Creation
0 likes · 5 min read
Understanding Java String Object Creation and Memory Allocation
Selected Java Interview Questions
Selected Java Interview Questions
Jul 2, 2022 · Backend Development

Understanding Java String Constant Pool and the Behavior of String.intern() Across JDK Versions

This article explains the Java constant pool concept, details how the String constant pool works in different JDK versions, demonstrates the effects of String.intern() with code examples, and discusses practical applications and pitfalls of using intern for memory optimization and synchronization.

Constant PoolJVMMemory Optimization
0 likes · 16 min read
Understanding Java String Constant Pool and the Behavior of String.intern() Across JDK Versions
ITPUB
ITPUB
Dec 8, 2020 · Fundamentals

Why Does Java’s String Have a 65,534‑Character Limit? Deep Dive into JVM Specs

Java’s String length is bounded by both the int‑based array limit (≈2 billion characters) and a JVM compile‑time restriction of 65,534 characters due to the constant‑pool’s u2 index, a nuance explained through source code examples, JVM spec excerpts, and a practical experiment.

Constant PoolJVMLength Limit
0 likes · 8 min read
Why Does Java’s String Have a 65,534‑Character Limit? Deep Dive into JVM Specs
Programmer DD
Programmer DD
Nov 29, 2020 · Backend Development

Why Does Java Limit String Literals to 65,534 Characters?

This article explains how Java stores strings using a char array, the theoretical maximum length of 2^31‑1 characters, and why the JVM limits string literals to 65,534 characters due to constant‑pool u2 indexing, illustrated with code examples and a practical experiment.

Constant PoolJVMLength Limit
0 likes · 9 min read
Why Does Java Limit String Literals to 65,534 Characters?
Top Architect
Top Architect
Nov 26, 2020 · Fundamentals

Understanding Java String Length Limits: JVM Specification, Constant‑Pool Constraints, and Practical Experiments

This article explains why Java strings have length limits, detailing the char[] storage, the int‑based array size ceiling, the JVM constant‑pool u2 restriction of 65535 bytes, and demonstrates a compile‑time experiment building a 65,534‑character literal to illustrate the practical impact.

Constant PoolJVMLength Limit
0 likes · 8 min read
Understanding Java String Length Limits: JVM Specification, Constant‑Pool Constraints, and Practical Experiments
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Apr 18, 2020 · Backend Development

Understanding How new String Creates Objects and the Role of the String Constant Pool in Java

This article explains why the new String("xxx") expression may create one or two objects depending on the presence of the literal in the JVM's string constant pool, demonstrates the behavior with compiled bytecode and runtime examples, and clarifies common interview misconceptions about Java string object creation.

Constant PoolJVMObject Creation
0 likes · 12 min read
Understanding How new String Creates Objects and the Role of the String Constant Pool in Java
Architecture Digest
Architecture Digest
Dec 11, 2019 · Fundamentals

Understanding Java String Concatenation, Constant Pool, and Bytecode Behavior

This article explains how Java handles String literals and concatenation, detailing the roles of the String constant pool, the effects of the '+' operator invoking StringBuilder.append, the placement of resulting strings in the heap versus the pool, and demonstrates these concepts through bytecode analysis and code examples.

Constant PoolMemory ManagementString
0 likes · 12 min read
Understanding Java String Concatenation, Constant Pool, and Bytecode Behavior
Java Captain
Java Captain
Dec 18, 2017 · Fundamentals

Understanding Java Constant Pool: Theory and Practice

This article explains the Java constant pool, distinguishing static and runtime pools, demonstrates string interning behavior with code examples, and shows how to inspect class files and memory settings to observe constant pool effects in the JVM.

Constant PoolJVMMemory Management
0 likes · 9 min read
Understanding Java Constant Pool: Theory and Practice