public class X {
    public static void main(String[] args) {
        String s1=" abc xyz ";
        System.out.println(s1.length());
        s1.trim();
        System.out.println(s1.length());
        System.out.println(s1.trim().length());
    }
}
O/p:
9
9
7
Kindly explain to me why s1.trim().length() is 7 and not 9 as s1 will still be pointing to the old string ie " abc xyz " ?
 
     
     
    