public class Shuzizifupaixu {
public static void main(String[] args) {
String s ="45,12,69,72,88,91,23";
String[] strArry = s.split(" ");//把s定义成一个字符串数组
int[] arr = new int[strArry.length];
for (int i = 0; i < arr.length; i++) {
arr[i] = Integer.parseInt(strArry[i]);
}
Arrays.sort(arr);
StringBuffer sb = new StringBuffer();
for (int y = 0; y < arr.length; y++) {
sb.append(arr[y]).append(" ");
String result = sb.toString().trim();
System.out.println(result);
}
}
}
|
|