数组定义的几种方式

因为经常对定义的一个格式容易出错,特此记录:

数组的定义有:

  1. int[ ] arr = new int[长度];
  2. int[]   arr = {1,2,4,5};//同时初始化了
  3. int[]    arr = new int[]{1,2,3,6,8};// 注意后面new int[]  -------这个【】里面可以不写;

猜你喜欢

转载自blog.csdn.net/qq_32367263/article/details/81392569