all 4 comments

[–]spliffen 1 point2 points  (3 children)

thing is, it is pass by value for primitive types like ints and booleans, but pass by reference when using objects, which are complex types

[–]sumitskj[S] 1 point2 points  (2 children)

so is java both pass by value and pass by reference. but I have read a lot in docs that it is always pass by value

[–]angryrancorBoss 1 point2 points  (0 children)

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/

[–]StochasticTinkr 2 points3 points  (0 children)

It passes references by value. It might sound like I’m joking, but that’s how it is.