[Solved] Why you can’t just paste method to make it work?


String is immutable. so, sub.toUpperCase() doesn’t change the string internals. It just returns you a new string value that is uppercased:

To uppercase sub, rather assign sub to the result of the toUpperCase() method like so:

sub = sub.toUpperCase();

That way, you return a new uppercase string.

solved Why you can’t just paste method to make it work?