首页 > 其他分享 >ArrayDmeo06

ArrayDmeo06

时间:2023-10-25 16:58:30浏览次数:29  
标签:Arrays System int toString ArrayDmeo06 println out

package com.chen.array;

import java.util.Arrays;

public class ArrayDmeo06 {
public static void main(String[] args) {
int[] a ={1,22,51,498,51,32,2};
printArrays(a);
//System.out.println(a); //[I@4554617c


//打印数组元素Arrays.toString:
System.out.println(Arrays.toString(a));

Arrays.sort(a);//数组进行排序 : 升序
System.out.println(Arrays.toString(a));

Arrays.fill(a,2,6,0);
System.out.println(Arrays.toString(a));

}
public static void printArrays(int[] a){
for (int i = 0; i < a.length; i++) {
if (i==0){
System.out.print("[");
}
if (i==a.length-1){
System.out.print(a[i]+"]");
}else {
System.out.print(a[i] + ",");
}
}
}
}

标签:Arrays,System,int,toString,ArrayDmeo06,println,out
From: https://www.cnblogs.com/jingyichenloveningning/p/17787579.html

相关文章