Jdk 6 學習記錄

java.util.Arrays 類

// 天然排序
Arrays.sort(Object[] obj);

// 天然排序,在指定範圍內
Arrays.sort(Object[] obj,int fromIndex,int toIndex);

// 在數組中找指定Key,返回索引(沒找到 -1,使用該方法以前最好使用Sort先進行排序,否則結果不許確)
Arrays.binarySearch(Object[] obj,Object key);

// 在數組中找指定Key,返回索引(沒找到 -1,使用該方法以前最好使用Sort先進行排序,否則結果不許確),指定範圍
Arrays.binarySearch(Object[] obj,int fromIndex,int toIndex,Object key);

// 用指定值填充指定數組
Arrays.fill(Object[] obj, Object val);

// 在指定範圍內用指定值填充指定數組
Arrays.fill(Object[] obj,int fromIndex,int toIndex, Object val);

// 數組拷貝,生成新的數組
static <T> T[] copyOf(T[] obj,int newLength);

// 對於引用類型,仍是屬於淺拷貝
Arrays.copyOf(T[] obj,int newLength);

// 指定範圍進行數組拷貝,生成新的數組
Arrays.copyOfRange(T[] obj, int from, int to);

// 把指定數組轉換成List,和Collection接口創建了橋樑,生成List<T>
Arrays.asList(T...a)
相關文章
相關標籤/搜索