In Java, I am doing this to trim a string:
String input = \" some Thing \"; System.out.println(\"before->>\"+input+\"<<-\"); input = input.trim(
Yes, but there will still be two objects until the garbage collector removes the original value that input was pointing to. Strings in Java are immutable. Here is a good explanation: Immutability of Strings in Java.