When we pass values to methods in Java, it's always pass by value. However, when we pass an object instead of a primitive, we're actually passing the value of its memory address, or the address of where the variable value is actually stored. This means when you pass in an object to a method, you're not making a copy of the object. You are passing a variable that points to the same object. However, once you make any changes inside the method with the object, you won't be making any changes to the object that was passed in when calling this method.
Back to top© 2019–2025 Jeffrey Wang. All rights reserved.
In loving memory of Haskell, 19??-2001.