Because you can't change a String anywhere. They're immutable.
It doesn't matter whether it's in a List or not.
Your line s = s + " of steel!"; creates a new String and assigns it to s. The fact that the original reference pointed to a String you placed in a List is irrelevant.
Bear Bibeault wrote:Because you can't change a String anywhere. They're immutable.
It doesn't matter whether it's in a List or not.
Your line s = s + " of steel!"; creates a new String and assigns it to s. The fact that the original reference pointed to a String you placed in a List is irrelevant.