1、明数组的语法:
数据类型[ ] 数组名;
或者 数据类型 数组名[ ];
int[] scores;
String names[];
2、对声明的数组分配空间:
语法: 数组名 = new 数据类型 [ 数组长度 ];
scores = new int [10];
names = new String[100];
3、也可以定义时直接对数组赋值:
int[] ids ={1,2,3,4};
或 int[] ids = new int[] {1,2,3,4};
1、明数组的语法:
数据类型[ ] 数组名;
或者 数据类型 数组名[ ];
int[] scores;
String names[];
2、对声明的数组分配空间:
语法: 数组名 = new 数据类型 [ 数组长度 ];
scores = new int [10];
names = new String[100];
3、也可以定义时直接对数组赋值:
int[] ids ={1,2,3,4};
或 int[] ids = new int[] {1,2,3,4};
转载于:https://my.oschina.net/u/2354196/blog/464929