Submission timeline
2007–2026One 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 orderWell 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…
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…
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.
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
- Total points
- 398
- Total comments
- 443
100+ points or 50+ comments
reference only — not used in Hall rules or ranking
reference only — not used in Hall rules or ranking
Every submission
| Date | Title as submitted | By | Points | Comments |
|---|---|---|---|---|
| 2010-12-01 | Java is Pass-by-Value, Dammit | m0th87 | 9 | 12 |
| 2013-06-20 | Java is Pass-by-Value, Dammit | caberus | 1 | 0 |
| 2014-10-13 | Java is Pass-by-Value, Dammit | thisjepisje | 6 | 1 |
| 2015-03-22 | Java is Pass-by-Value, DammitFirst breakout · Best thread | xvirk | 218 | 243 |
| 2018-04-22 | Java is Pass-by-ValueHall induction · Latest 20+ point return | jxub | 164 | 187 |
