String withSpaces = " Hi "; String withoutSpaces = withSpaces.trim();
String str = "Hello "; System.out.println(str.trim()); // "Hello"