String ss1 = "123 34 54 34 23 12";
//字符串 ---字符串数组
String[] strArray = ss1.split(" ");
int[] arr = new int[strArray.length];
for (int i = 0; i < arr.length; i++) {
arr[i] = Integer.parseInt(strArray[i]);
}
//int数组排序
Arrays.sort(arr);
//把排序后的int[] 转为 String
StringBuffer sb = new StringBuffer();
for (int i = 0; i < arr.length; i++) {
sb.append(arr[i]).append(" ");
}
String result = sb.toString().trim();
System.out.println(result); |
|