《把一个英语句子中的单词次序颠倒后输出》

import org.junit.Test;


public class index {
@Test
public void index(){
    String str = "how.my are you";
    if("".equals(str) || str==null){
      System.out.println("没有可用数据");
    }
    else{
    String strs[] = str.split("\s+|[.]");
    StringBuffer restr = new StringBuffer();
    for(int i = strs.length-1; i >= 0; i--){
      System.out.println(strs[i]);
      restr.append(" "+strs[i]);
    }
    System.out.println("反:"+restr);

    }

}
}

原文地址:https://www.cnblogs.com/a4yy/p/5368138.html