Reverse Words in a String

 1 public class Solution {
 2     /**
 3      * @param s : A string
 4      * @return : A string
 5      */
 6     public static String reverseWords(String s){
 7         if (s == null || s.isEmpty()){
 8             return s;
 9         }
10         String result = "";
11         String[] strings = s.split(" ");
12         for (int index = strings.length - 1; index >= 0; index--){
13             result = result.concat(strings[index]).concat(" ");
14         }
15         return result.trim();
16     }
17 }
原文地址:https://www.cnblogs.com/CuiHongYu/p/7086020.html