Arrays类的学习摘要:

Arrays类:       java.util.Arrays


此类包括用来操作数组(比如排序和搜索)的各种方法。
此类还包含一个允许将数组作为列表来查看的静态工厂。
***********************************************************************************************************************************
1、asList(T...a);
public static <T> List<T> asList(T... a)






还没怎么弄懂!!!!!!!
***********************************************************************************************************************************


2、binarySearch();
public static int binarySearch(byte[] a,byte key);————————>必须先实现sort(byte[]);然后数组按升序排序了


 ————————>key是查找的值,返回key在排序号的数组中的角标


public static int binarySearch(byte[] a,int fromIndex,int toIndex,byte key)
 
 ————————>必须先实现sort(byte[] a,int fromIndex,int toIndex);同上。
————————其他基本类型的同上(byte[],char[],short[],int[],long[],float[],double[],boolean[])没有、String.——————————


难点:
public static int binarySearch(Object[] a,Object key)
public static int binarySearch(Object[] a,int fromIndex,int toIndex,Object key)


public static <T> int binarySearch(T[] a,T key,Comparator<? super T> c)
public static <T> int binarySearch(T[] a,int fromIndex,int toIndex,T key,Comparator<? super T> c)


***********************************************************************************************************************************

3、copyof(origarr,newlength);
public static int[] copyOf(int[] original,int newLength)
 ————————>复制指定长度的数组

————————其他基本类型的同上(byte[],char[],short[],int[],long[],float[],double[],boolean[])没有、String.——————————




难点:
public static <T> T[] copyOf(T[] original,int newLength)
public static <T,U> T[] copyOf(U[] original,int newLength,Class<? extends T[]> newType)
 ————————>注意:newType,返回数组属于newType类。


 ————————>还不会用!!!
***********************************************************************************************************************************


4、copyOfRange(origarr,from,to);
public static int[] copyOfRange(int[] original,int from,int to);
 ————————>将指定数组的指定范围复制到一个新数组。


————————其他基本类型的同上(byte[],char[],short[],int[],long[],float[],double[],boolean[])没有、String.——————————


难点:
public static <T> T[] copyOfRange(T[] original,int from,int to)
public static <T,U> T[] copyOfRange(U[] original,int from,int to,Class<? extends T[]> newType)


 ————————>还不会用!!!
***********************************************************************************************************************************


5、“深层内容”
Arrays.deepEquals(arr4, arr5);————————>public static boolean deepEquals(Object[] a,Object[] a2)
Arrays.deepHashCode(arr3);——————————>public static int deepHashCode(Object[] a)
Arrays.deepToString(arr3);——————————>public static String deepToString(Object[] a)


 ————————>还不会用!!!
***********************************************************************************************************************************
6、equals(arr1,arr2)
public static boolean equals(int[] a,int[] a2) ————————>如果两个指定的 int 型数组彼此相等,则返回 true。


————————其他基本类型的同上(byte[],char[],short[],int[],long[],float[],double[],boolean[])没有、String.——————————


***********************************************************************************************************************************
7、fill(arr,val)  or  fill(arr,from,to,val) 
public static void fill(int[] a,int val)————————————>将指定的 int 值分配给指定 int 型数组的每个元素。
public static void fill(int[] a,int fromIndex,int toIndex,int val)将指定的 int 值分配给指定 int 型数组指定范围中的每个元素


难点:public static void fill(Object[] a,Object val)————————>还不会用!!!
***********************************************************************************************************************************
8、hashCode(arr)


***********************************************************************************************************************************
9/sort(arr)  or  sort(arr,from,to)
public static void sort(int[] a)————————>对指定的 int 型数组按数字升序进行排序。该排序算法是一个经过调优的快速排序法
(Object a)
public static void sort(int[] a,int fromIndex,int toIndex)————————>对指定 int 型数组的指定范围按数字升序进行排序。
(Object a)
————————其他基本类型的同上(byte[],char[],short[],int[],long[],float[],double[],boolean[])没有、String.——————————
难点:
public static <T> void sort(T[] a,Comparator<? super T> c)————————>根据指定比较器产生的顺序对指定对象数组进行排序。
public static <T> void sort(T[] a,int fromIndex,int toIndex,Comparator<? super T> c)
 ————————>根据指定比较器产生的顺序对指定对象数组的指定范围进行排序。
***********************************************************************************************************************************
10、toString(arr)
public static String toString(int[] a)————————>返回指定数组内容的字符串表示形式。相邻元素用字符 ", "(逗号加空格)分隔。


————————其他基本类型的同上(byte[],char[],short[],int[],long[],float[],double[],boolean[])没有、String.——————————


***********************************************************************************************************************************











































评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值