初始化
package com.wzt.www.array;
/**
* @author WZT
* @create 2021-03-26 17:25
*/
public class ArrayDemo02 {
public static void main(String[] args) {
//静态初始化:创建+赋值
int[] a = {
1,2,3,4,5,6,7,8,9,10};
System.out.println(a[2]);
//动态初始化:包含默认值
int[] b = new int[10];
b[0] = 10;
System.out.println(b[0]);
System.out.println(b[3]);
}
}
输出
3
10
0
~~~![在这里插入图片描述](https://img-blog.csdnimg.cn/20210326173202461.bmp?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTgwOTgzOA==,size_16,color_FFFFFF,t_70#pic_center)