Java is a “pass-by-value” language, meaning that when an argument is passed to a method, a copy of the value of the argument is made and passed to the method.
This copy is independent of the original value, so any changes made to the argument within the method will not affect the original value. However, if the argument is an object reference, the reference itself is passed by value.
This means that a copy of the reference is passed to the method, but the object that the reference points to is not copied. As a result, any changes made to the object within the method will affect the original object. It’s important to keep this distinction in mind when working with objects in Java.