package com
public class Hello {
public static void main(String[] args) {
System
System
System
System
System
System
}
public static String reverseWords(String str) {
int start =
int end =
char[] chs = str
//
reverseCharactersInRange(chs
//
for (int i =
if (Character
// 找到組成單詞的字符的起始和結束位置
if (start > end) {
start = end = i;
} else {
++end;
}
} else {
if (start < end) {
reverseCharactersInRange(chs
}
start = chs
}
}
if (start < end) {
reverseCharactersInRange(chs
}
return new String(chs);
}
public static void reverseCharactersInRange(char[] chs
int times = (end
for (int i =
char temp = chs[start + i];
chs[start + i] = chs[end
chs[end
}
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26906.html