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!
To fully understand the concept of this Java Code Challenge, check out the following video explanation:
That’s it challenger, keep it up improving your skills! Never stop learning!
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.