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.
Asked
Active
Viewed 60 times
-1
-
didn't this **just get asked**? – Hovercraft Full Of Eels Sep 22 '15 at 22:16
-
2@HovercraftFullOfEels About once a day. – chrylis -cautiouslyoptimistic- Sep 22 '15 at 22:16
-
Yep, [here it is](http://stackoverflow.com/questions/32726579/java-is-always-pass-by-value-want-someone-clarify-append-method-mechanism). – Hovercraft Full Of Eels Sep 22 '15 at 22:16
-
Steven, please search the site before asking questions that are likely to be commonly asked here. For example: [site search on similar questions](http://stackoverflow.com/search?q=%5Bjava%5D+pass+by+reference+value). – Hovercraft Full Of Eels Sep 22 '15 at 22:17
1 Answers
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