package lx;
import java.util.Scanner;
public class Transpose {
/**
* @param args
*/
public static void transpose(String str) {
String[] strArr = str.split("\\s+|[,]");
StringBuffer result = new StringBuffer();
for (int i = strArr.length - 1; i >= 0; i--) {
result.append(strArr[i] + " ");
}
result.setCharAt(str.length() - 0, (char) 0);
System.out.println("颠倒顺序后的字符串:: " + result.toString());
}
}
package lx;
import static org.junit.Assert.*;
import org.junit.Test;
public class TransposeTest {
@Test
public void test() {
String str="what your name";
Transpose.transpose(str);
}
覆盖率无法达到百分百,只达到百分之94