Tagged articles
2 articles
Page 1 of 1
Senior Brother's Insights
Senior Brother's Insights
Sep 6, 2020 · Fundamentals

Is Java Pass‑by‑Value or Pass‑by‑Reference? A Deep Dive into Method Parameter Passing

This article demystifies Java's method‑parameter passing by analyzing code examples with primitives, strings, and objects, illustrating how the JVM copies values—including reference addresses—so that arrays appear mutable while reassigning a String or object reference does not affect the original variable.

memory-modelmethod-parameterspass-by-value
0 likes · 10 min read
Is Java Pass‑by‑Value or Pass‑by‑Reference? A Deep Dive into Method Parameter Passing
FunTester
FunTester
Aug 24, 2019 · Fundamentals

Why Java Can't Swap Primitive Values Inside a Method – The Correct Way

This article explains that Java passes primitive arguments by value, so attempts to swap two ints inside a method have no effect on the caller, and demonstrates both the faulty implementation and the proper solutions using a temporary variable or a return value.

JavaSwapfundamentals
0 likes · 4 min read
Why Java Can't Swap Primitive Values Inside a Method – The Correct Way