Did you know that every variable in Java is passed by value and not by reference? However, what happens when we pass an object to a method? Do we manipulate the value or the reference? This is exactly what you will explore in the following Java Challenge!
It’s time for the Java Code Challenge then!
Join the discussion
2 comments
Great example of mutability 🙂
And mutability should be avoided if possible. For example, the StringBuilder is not thread-safe, so invoking the method by multiple threads would have unpredictable results.