数组

//方法1
int array1[] = {1,2,3,4};
//方法2
int[] array2 =new int[5];
//方法3
byte array3= new byte[]{1,2,3,4};  

例:

结果输出3个0,因为虽然为score开辟了3个内存空间,但并未为其赋值,int的默认值是0,所以输出3个0

 

第一个for循环为其每个下标赋值,第二个for循环输出每个下标的值,结果为1,2,3

 

数组的应用

posted @ 2015-05-07 22:03  sflik  阅读(128)  评论(0编辑  收藏  举报