- 数组的概念:数组是一组相同类型的数据的集合
- 创建一维数组:
int[] arr1 = new int[5];
int[] arr2 = {1, 2, 3, 4};
int arr3[] = new int[]{1, 2,3,4};
int arr4[] = {1, 2, 3, 4};
数组类型[][] 数组名称;
数组类型 数组名称[][];
int arr1[][] = new int[2][4]
int arr2[][] = new int[2][]
arr2[0] = new int[3]
arr2[1] = new int[4]
int[][] arr3 = {{1, 2}, {3, 4}}
- 二维数组遍历:按照下标依次遍历
- 数组填值:Arrays.fill(int[] a, int fromIndex ,int stopIndex, int value)
- 数组排序:Arrays.sort(数组名称)
- 复制数组:Arrays.copyOf(数组名称, 数组长度);
- 复制数组:Arrays.copyOfRange(数组名称, int formIndex, int toIndex)
- 数组查询:结果为元素在数组中对应的位置;Arrays.binarySearch(数组名称,int formIndex, int toIndex, 查询值)
- 数组的排序算法:待补充