package cn.zhan.fz;
import java.util.Scanner;
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.print("请输入要测试的字符串:");
String str = input.nextLine();
test.test(str);
}
public static void test(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 cn.zhan.fz;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
public class testTest {
@Before
public void setUp() throws Exception {
}
@Test
public void test() throws Exception {
String str="how are you";
test.test(str);
}
}