Java 学习笔记(2)

数组

声明数组的形式如下

//声明一个定长的数组
int[] a = new int[100];

int[] a;
a = new int[100];

int a[] = new int[100];

int a[];
a = new int[100];

//声明时进行初始化
int[] a = new int[] {5, 15, 20};

int[] a;
a = new int[] {5, 15, 20};

int[] a = {5, 15, 20};

int a[] = new int[] {5, 15, 20};

int a[];
a = new int[] {5, 15, 20};

int a[] = {5, 15, 20};

数组声明时写成int a[]int[] a均可

Last modification:June 18th, 2020 at 12:03 pm
如果觉得我的文章对你有用,请随意赞赏