/**
实现单词的倒序,并且不能有空格
*//
package TsetOO;
public class TestString {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = " hellow my son ";
int last = str.length()-1;
int frist = 0;
char ch[] = str.toCharArray();
for (int i = 0; i < ch.length; i++) {
if (ch[i] != ' ') {
break;
}else {
frist =i;
}
}
while(frist<last){
if (ch[last] == ' ') {
last=last-1;
}else{
int l = last;
while(ch[last] != ' '){
last--;
}
int d = last+1;
for(int i = d;i<=l;i++){
System.out.print(ch[i]);
}
if (frist != last) {
System.out.print(" ");
}
}
}
}
}