Is Java “pass-by-reference” or “pass-by-value”?

0 like 0 dislike
17 views

I always thought Java was pass-by-reference.

However, I've seen a couple of blog posts (for example, this blog) that claim that it isn't.

I don't think I understand the distinction they're making.

What is the explanation?

by (550 points) | 17 views

1 Answer

0 like 0 dislike

I believe that much of the confusion on this issue has to do with the fact that different people have different definitions of the term "reference". People coming from a C++ background assume that "reference" must mean what it meant in C++, people from a C background assume "reference" must be the same as "pointer" in their language, and so on. Whether it's correct to say that Java passes by reference really depends on what's meant by "reference"

by (1.2k points)

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
asked May 12, 2019 by Nikita07
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
1,117 users