package two;
import java.util.Scanner;
public class TestTwo {
public static void Testtwo(String str) {
// TODO Auto-generated method stub
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 two;
import static org.junit.Assert.*;
import org.junit.Test;
public class TestTwoTest {
@Test
public void test() {
String str = "how are you";
TestTwo.Testtwo(str);
}
}
时间: 2024-11-04 20:06:41