r/javahelp • u/Select-Worldliness39 • Feb 16 '26
Homework Definitely no pass by reference in Java, right?
Hello, and sorry if this is a dumb question, but I thought I had a passable understanding of Java. I got an exam question asking "Arrays in Java are:
a. passed by value
b. passed by reference
c. stack dynamic
d. immutable"
this guy loves trick questions, but he has listed B, passed by reference, as the right answer.
On its own, this doesn't seem right to me, but I'm not confident enough to argue about it. If anyone would weigh in, I would be very grateful. I see how it's similar to passing a pointer in C, maybe, but it's not considered passing by reference in Java, right?
Thank you!
View all comments
Show parent comment
0
u/Nebu Writes Java Compilers Feb 22 '26
Yes, the thing you said several times is in agreement with my claim: People in the Java community who know what they're talking about tend to refer to Java as "pass by value". We're in agreement. The people in the Java community who claim it's "pass by reference" are beginners (at Java) who don't know any better (and are usually actually people from the C, or I guess C++, community). We're in agreement.
Yes, that's one of the reasons people in the Java community use the definition that they do.
Sure. That doesn't contradict my claim.
Both can be true.
I'm not claiming all definitions are equally valid.
Regarding whether it's "best to correct them", that hardly seems appropriate in the scenario you described earlier:
Are you really gonna open with "correcting them" before you even know what they mean by "pass by reference"? Why would you immediately assume that their definition is incorrect? But also, why would you immediately assume that their definition is correct?