-1

I don't have an exact example, but i know that some Java methods can modify the parameters passed to it, and where the method was called can use these modified values.

Steven
  • 319
  • 1
  • 3
  • 7

1 Answers1

1

Java is pass by value - always.

Primitives like int, double, and boolean are obviously pass by value. You can't alter those parameters.

Instances of Java classes have their references passed by value into method. The references themselves are immutable - you can't write a swap method in Java the way you can with C pointers.

But if the references point to mutable objects you can change their state.

duffymo
  • 305,152
  • 44
  • 369
  • 561