动态初始化数组
数组的元素默认值
-
byte、short、char、int、long、char类型定义的数组,初始化默认是0
-
类、接口、数组、String类型定义的数组,默认值是null
-
float、double类型定义的数组,默认值是0.0
-
boolean类型定义的数组,默认值是false
//初始化写法
// 数据类型 [] 数组名 = new 数据类型 [长度];
int[] kawayis = new int[5];
kawayis[0]=2;
System.out.println(kawayis[0]);
System.out.println(kawayis[1]);
//1.整型数组的元素默认值是0;
int [] arr =new int[10];
System.out.println(arr[0]);
System.out.println(arr[9]);

浙公网安备 33010602011771号