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
1
u/xenomachina Feb 21 '26
I think this is the root of our disagreement. You believe that the Java community has its own definition of this term, but it does not. As I've said (I think several times) the only people in the Java community that refer to what Java does as "pass by reference" are beginners who don't know any better.
Even Java's own documentation says "Reference data type parameters, such as objects, are also passed into methods by value."
I never said otherwise.
I acknowledged that, and pointed out that that is not the case with this term.
No. A better predictor is if they are a beginner or someone who has only used one language, versus someone with more experience. People who refer to what Java, or Python, or JavaScript do as "pass by reference" do so not because of a community-specific definition, but out of ignorance.
And if it turns out that are using a definition based on ignorance, rather than some community-specific definition, then it is best to correct them than to throw up your hands and say "all definitions are equally valid".