【Java基础】【狂神说Java】Java零基础学习视频通俗易懂P52-59(数组)(Day3-20210702)
作者:互联网
1 数组
静态初始化:创建+赋值
动态初始化:包含默认初始化
package array;
import java.lang.reflect.Array;
import java.util.Arrays;
public class Demo01 {
public static void main(String[] args) {
int[] a=new int[10];
System.out.println(a);
System.out.println(Arrays.toString(a));
Arrays.fill(a,10);
System.out.println(Arrays.toString(a));
Arrays.fill(a,2,5,99);
System.out.println(Arrays.toString(a));
}
}
输出
[I@1b6d3586
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
[10, 10, 99, 99, 99, 10, 10, 10, 10, 10]
压缩数组
标签:10,20210702,Arrays,System,Day3,99,println,Java,out 来源: https://blog.csdn.net/kz_java/article/details/118416731