Java – Does Java pass by reference?


Does Java really support passing by reference?

If it doesn't, why do we have the == operator for finding two objects with the same reference?

Best Solution

Java uses pass by value, not by reference...

But, for non primitive types the value is the value of the reference.

So == compares the values of references for Objects.