Java中的数组是一组相同数据类型的元素的集合。以下是一些常见的Java数组操作:
int[] myArray = {1, 2, 3, 4, 5};
或者:
for (int i = 0; i < myArray.length; i++) { myArray[i] = i; }
for (int i = 0; i < myArray.length; i++) { System.out.println(myArray[i]); }
for (int x : myArray) { System.out.println(x); }
int[] myNewArray = Arrays.copyOf(myArray, myArray.length);
Arrays.sort(myArray);
int index = Arrays.binarySearch(myArray, 5);
原文链接:codingdict.net