r/code • u/sumitskj • Jan 30 '25
Java Is java not pass by reference?
As per what I know when i pass some parameters to a function they get modified. but in docs it says java is pass by value. I am not getting it.
Also I watched this video: https://www.youtube.com/watch?v=HSPQFWEjwR8&ab_channel=SumoCode
but I am not getting it. can anyone explain
2
Upvotes
View all comments
Show parent comment
2
u/angryrancor Boss Jan 30 '25
Like /u/spliffen said, it's pass by value for primitive data types, and pass by reference for Object data types. I think you may be not understanding primitive vs Object? This should clear it up for you: https://www.geeksforgeeks.org/primitive-data-type-vs-object-data-type-in-java-with-examples/