HN Hall of Fame Weekly email

Java is Pass-by-Value, Dammit

Screenshot of javadude.com captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 5 calendar years, with breakout response in 2 of them.

submissions
5
submitters
5
observed span
2010–2018
peak thread · 243 comments
218 pts
latest 20+ return · 2018-04-22
164 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

Well the way I've always thought of it is that Java passes "references by value". Meaning the target method receives a _copy_ of the pointer, not the actual pointer. So the result of newing up the parameter inside the target method doesn't affect the original, because you're just making the pointer point to a NEW memory address. On the other hand, mutating the parameter WILL affect the original object, because a copy of a pointer still points to that object…

This article is overly pedantic. Java's semantics are pass-by-value only of you consider that the "values" that are being passed are pointers. But Java doesn't have first-class pointers, it has implicit pointers. The only thing you can do with a Java pointer "value" is to tacitly dereference it. In fact, you can write a swap(x,y) function in Java. It goes something like this: class foo { int value } void swap(foo x, foo y} { int temp = x.value; x.value…

lisper·164-point thread·

Good post.... I am a Java developer with almost 10 yrs of experience and I know I often make that mistake even on Job interviews:).... The problem is that people used to Java tend to think more about the intuitive consequence of passing by ref vs value. When a Java dev thinks of passing by reference he's thinking: "I can alter the state of the reference and the changes would be visible globally, including from within the calling context". In…

Edmond·9-point thread·

If "Object references are passed by value", then the "Object" itself is passed by reference, so the statement "In Java, Objects are passed by reference" it is a full true statement. You can pass "Object references" by value or by reference, anyway, since you're passing a "Object reference", the object itself is being passed as a reference.

lucio·6-point thread·

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
2

100+ points or 50+ comments

Total points
398

reference only — not used in Hall rules or ranking

Total comments
443

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2010-12-01Java is Pass-by-Value, Dammitm0th87912
2013-06-20Java is Pass-by-Value, Dammitcaberus10
2014-10-13Java is Pass-by-Value, Dammitthisjepisje61
2015-03-22Java is Pass-by-Value, DammitFirst breakout · Best threadxvirk218243
2018-04-22Java is Pass-by-ValueHall induction · Latest 20+ point returnjxub164187