Day6 数组

数组的定义:存储一组相同类型的数据
数组类型[ ] 数组名 = new 数组类型 [数组的长度];
int[] scores = new int[3];
scores[0]=80;
scores[1]=90;
scores[2]=100;
//int[3]=100; 数组下标越界
int[]scores=new int[]{80,90,100};
int[]scores={80,90,100};
数组元素分配的初始值
整型的默认值:0;
浮点型的默认值:0.0
char的默认值:’\u0000’
boolean:false;
String的默认值:null

猜你喜欢

转载自blog.csdn.net/weixin_43766697/article/details/84761499