In Java, I am doing this to trim a string:
String input = \" some Thing \"; System.out.println(\"before->>\"+input+\"<<-\"); input = input.trim(
As strings in Java are immutable objects, there is no way to execute trimming in-place. The only thing you can do to trim the string is create new trimmed version of your string and return it (and this is what the trim() method does).
trim()