格式 : 元素类型[] 数组名 = new 元素类型(元素个数或数组长度)
int[] arr = new int[]{1,2,3,4};
--静态的方式
int[] arr = {1,2,3,4};-----------------------------------------------
使用情况:
需要一个容器,但不明确容器的具体是数据
int arr[] = new int[3];
需要一个容器,存储已知的具体数据
int arr[] ={1,2,3,4};本文共 292 字,大约阅读时间需要 1 分钟。
格式 : 元素类型[] 数组名 = new 元素类型(元素个数或数组长度)
int[] arr = new int[]{1,2,3,4};
--静态的方式
int[] arr = {1,2,3,4};-----------------------------------------------
使用情况:
需要一个容器,但不明确容器的具体是数据
int arr[] = new int[3];
需要一个容器,存储已知的具体数据
int arr[] ={1,2,3,4};转载于:https://www.cnblogs.com/liyunchuan/p/10565370.html