0

In Java sometimes method parameters act like passed by reference, even though they are not. what method are they passed by?

I know java is always passed by value. But is it possible that it could act like pass by reference

  • The reference variable(usually an instance of a class) stores the memory address of the object, not the object itself. So, if you pass an object as a parameter, the method copies the 'address' of the variable. That's why it looks like passing by reference. – March3April4 Sep 28 '17 at 05:15
  • 1
    https://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value?rq=1 I think looking at this will be helpful. – March3April4 Sep 28 '17 at 05:20

1 Answers1

1

All parameters are passed by value.

Visit https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html

swithen colaco
  • 157
  • 1
  • 12