Once you create a String in Java, you cannot change its contents. No method on String modifies the original. Every method that appears to change a string returns a brand-new String object instead.
Look at this example:
String name = "hello";
name.toUpperCase();
System.out.println(name);
This prints hello, not HELLO. The call to toUpperCase() created a new string, but you never stored it. To see the uppercase version, you need:
String name = "hello";
String upper = name.toUpperCase();
System.out.println(upper);
This behavior is called immutability. The String object itself never changes after creation. If you forget this and call methods without capturing the return value, your transformations silently do nothing.