public static void main(String[] args) {
int[] arr = { 1, 2, 6, 4, 5, 7, 8, 15, 19 };
// System.out.println("原数组:"+Arrays.toString(arr));
StringBuilder sb = new StringBuilder();
for (int x = 0; x < arr.length; x++) {
if (x == arr.length - 1) {
sb.append(arr[x]);
break;
}
sb.append(arr[x] + ",");
}
System.out.println("字符串:" + sb.toString());
} |