@Test
public void test1() {
String str1 = " h e llo wor ld ";
int begin = 0;
int end = str1.length() - 1;
while (begin <= end && str1.charAt(begin) == ' '){
begin ++;
}
while (begin <= end && str1.charAt(end) == ' '){
end --;
}
System.out.println(begin);
System.out.println(end);
String substring = str1.substring(begin, end+1);
System.out.println(substring);
}