字符串翻转
2018-09-12 本文已影响0人
ONEay
String:"this is my hello world"
结果:[world, hello, my, is, this]
/**
* 字符串翻转
* @param values
* @param reg 字符串split正则
*/
public static void reverse(String values,String reg) {
if (values == null ){
return;
}
String[] value = values.split(reg);
int a = 0 ;
int b = value.length-1;
while (a < b){
String temp = value[a];
value[a] = value[b];
value[b] = temp;
a++;
b--;
}
System.out.println(Arrays.toString(value));
}