You should give us code that demonstrates the problem, but I think you did something like this:
String str = "22 "; str.trim(); System.out.println(str.length());
But str.trim() does not change str (since strings are immutable). Instead, it returns a new string trim. So you need something like this:
String str = "22 "; str = str.trim(); System.out.println(str.length());
Mark peters
source share