Languagemedium0-2 years
Is Java pass-by-value or pass-by-reference?
Pass-by-value, always. For an object, the value that is copied is the reference — so a method can mutate the object the caller holds, but reassigning the parameter changes nothing outside the method.
PreviousWhat is the difference between the JDK, the JRE and the JVM?Next What happens if you override equals() but not hashCode()?
What happens if you override equals() but not hashCode()?Why are strings immutable in Java, and what does that cost?What is the difference between int and Integer? Where does autoboxing bite?What changed in switch, and why should a sealed switch have no default?How are overloading and overriding resolved differently?