package wj12301230;
import java.lang.reflect.Array;
import java.util.Arrays;
public class Test {
private static final String SEPARATOR=" ";
public static void main(String[] args) {
String numstr="23 10 -8 0 3 7 108";
String numstrs=SortNumberString(numstr);
System.out.println(numstrs);
}
private static String SortNumberString(String numstr) {
String[] numbers=toStringArray(numstr);//将字符串转化为多个数字格式的字符串数组;
int[] numint=toIntArray(numbers);
sort(numint);
return toString(numint);
}
private static String toString(int[] numint) {
StringBuilder sb=new StringBuilder();
for(int i=0;i<numint.length;i++) {
if(i!=numint.length-1)
sb.append(numint[i]+SEPARATOR);
else
sb.append(numint[i]);
}
return sb.toString();
}
private static void sort(int[] numint) {
Arrays.sort(numint);
}
private static int[] toIntArray(String[] numbers) {
int[] numint=new int[numbers.length];
for(int i=0;i<numbers.length;i++) {
numint[i]=Integer.parseInt(numbers[i]);
}
return numint;
}
private static String[] toStringArray(String numstr) {
return numstr.split(SEPARATOR);
}
}