更多 Java 基础知识方面的文章,请参见文集《Java 基础知识》
以 Java 7 API 为参照。
排序
void sort(int[] a)
void sort(int[] a, int fromIndex, int toIndex)
注意:包含 fromIndex
,不包含 toIndex
void sort(T[] a, Comparator<? super T> c)
The sorting algorithm is a Dual-Pivot Quicksort 使用快速排序
搜索
int binarySearch(int[] a, int key)
int binarySearch(int[] a, int fromIndex, int toIndex, int key)
判断相等
boolean equals(int[] a, int[] a2)
Two arrays are considered equal if both arrays contain the same number of elements, and all corresponding pairs of elements in the two arrays are equal.
填充
void fill(int[] a, int val)
void fill(int[] a, int fromIndex, int toIndex, int val)
复制
int[] copyOf(int[] original, int newLength)
truncated or padded with zeros to obtain the specified length
int[] copyOfRange(int[] original, int from, int to)
转换为链表
List<T> asList(T... a)
转换为字符串
String toString(int[] a)
引用:
Class Arrays