题目链接https://leetcode.cn/problems/reverse-words-in-a-string/视频讲解https://m.bilibili.com/video/BV1uT41177fXclass Solution { public String reverseWords(String s) { // 除去开头和末尾的空白字符 s s.trim(); // 正则匹配连续的空白字符作为分隔符分割 ListString wordList Arrays.asList(s.split(\\\\s)); Collections.reverse(wordList); return String.join( , wordList); } }