Java String trim does not work
===

    String rank = (some method);
    System.out.println("(" + rank + ")");

Outputs `(1  )`

I need to convert `rank` to type `int`(e.g., `Integer.parseInt(rank)`). 

First I have to remove the trailing spaces from the string `rank`. However, neither `rank.trim()` nor `rank.replace(" ","")` would work for me. The string `rank` just remains the same either way.

What's going wrong here?