日志文章

2019-12-15 aflfte2011

数组的初始化方式

package com.aflfte.arrays;
/**
 * 数组的初始化方式
 * @author root
 *1、静态初始化:直接符值给数组方法为:类型[] 数组名称={数组值};
 *2、默认初始化:指定数组的长度并不给其付植时系统就是默认对其付值;
 *3、动态初始化:通过数组的下标来分别对其付值就叫做动态初始化
 */
public class Test02 {
    public static void main(String[] args) {
        int[] a= {1,2,3,5};//数组静态初始化方法
        int[] b=new int[3];//数组的默认初始化
        int[] c=new int[2];
        c[0]=1;
        c[1]=3;//利用下标来符值就是动态初始化方式
        for(int e:a) {
            System.out.println(e);
        }
    }
}

« 飞机游戏实例练习 | 数组的使用»