Hacker News new | ask | show | jobs
by knappador 4100 days ago
Novice Java programmer reads title, mutates Java object inside function, later notices side-effects, and curses author of the title.

Second novice Java programmer reads title, wants to pass objects into functions, wants to avoid expensive stack copy and writes &myObject, gets compiler error, Googles "Java pointer," and curses author of the title.

Lesson learned: author of title is either unaware of the consequences such an interpretation will cause or seeks cursing as a source of attention.

1 comments

Novice Java programmer doesn't read title attempts to assign a new object to a variable inside a function, doesn't work, curses Java tutorial that said objects are pass by reference.
When in C, Python, Java, JS, or anything else does reassigning a variable from the function sig ever work? The symbol is in-scope. Even when overwriting the pointer location in C, you don't just assign; you de-reference and copy over the memory that was there. A novice programmer would make this mistake, not a novice Java programmer.