Arrays类包含用于操作数组的各种方法(例如排序和搜索)。 此类还包含一个静态工厂,允许将数组视为列表。

如果指定的数组引用为null,则此类中的方法都抛出NullPointerException ,除非另有说明。

方法:

常用:asList返回一个列表、copyOf复制新数组、toString()、sort排序

8:八大基本类型都有此方法

变量和类型方法描述
static <T> List<T> asList​(T... a)
返回由指定数组支持的固定大小的列表。
static int binarySearch​(Object[] a, int fromIndex, int toIndex, Object key)
使用二进制搜索算法搜索指定对象的指定数组范围。8
static int binarySearch​(Object[] a, Object key)
使用二进制搜索算法在指定的数组中搜索指定的对象。
static <T> int binarySearch​(T[] a, int fromIndex, int toIndex, T key, Comparator<? super T> c)
使用二进制搜索算法搜索指定对象的指定数组范围。
static <T> int binarySearch​(T[] a, T key, Comparator<? super T> c)
使用二进制搜索算法在指定的数组中搜索指定的对象。
static <T extends Comparable<? super T>>
int
compare​(T[] a, int aFromIndex, int aToIndex, T[] b, int bFromIndex, int bToIndex)
在指定范围内按字典顺序比较两个 Object阵列。8
static <T> int compare​(T[] a, int aFromIndex, int aToIndex, T[] b, int bFromIndex, int bToIndex, Comparator<? super T> cmp)
在指定范围内按字典顺序比较两个 Object阵列。
static <T extends Comparable<? super T>>
int
compare​(T[] a, T[] b)
Object顺序比较两个 Object阵列,在可比元素中。8
static <T> int compare​(T[] a, T[] b, Comparator<? super T> cmp)
使用指定的比较器按字典顺序比较两个 Object阵列。
static int compareUnsigned​(byte[] a, byte[] b)
byte字典顺序比较两个 byte阵列,数字处理元素为无符号。
static int compareUnsigned​(byte[] a, int aFromIndex, int aToIndex, byte[] b, int bFromIndex, int bToIndex)
在指定范围内按字典顺序比较两个 byte阵列,将元素数字处理为无符号。8
static boolean[] copyOf​(boolean[] original, int newLength)
使用 false (如有必要)复制指定的数组,截断或填充,以使副本具有指定的长度。
static byte[] copyOf​(byte[] original, int newLength)
使用零复制指定的数组,截断或填充(如有必要),以使副本具有指定的长度。8
static char[] copyOf​(char[] original, int newLength)
使用空字符复制指定的数组,截断或填充(如有必要),以使副本具有指定的长度。 
static <T> T[] copyOf​(T[] original, int newLength)
使用空值复制指定的数组,截断或填充(如有必要),以使副本具有指定的长度。
static <T,​U>
T[]
copyOf​(U[] original, int newLength, <? extends T[]> newType)
使用空值复制指定的数组,截断或填充(如有必要),以使副本具有指定的长度。
static <T> T[] copyOfRange​(T[] original, int from, int to)
将指定数组的指定范围复制到新数组中。8
static <T,​U>
T[]
copyOfRange​(U[] original, int from, int to, <? extends T[]> newType)
将指定数组的指定范围复制到新数组中。
static boolean deepEquals​(Object[] a1, Object[] a2)
如果两个指定的数组彼此 深度相等 ,则返回 true
static int deepHashCode​(Object[] a)
返回基于指定数组的“深层内容”的哈希码。
static String deepToString​(Object[] a)
返回指定数组的“深层内容”的字符串表示形式。
static boolean equals​(Object[] a, int aFromIndex, int aToIndex, Object[] b, int bFromIndex, int bToIndex)
如果在指定范围内指定的两个Object数组彼此 相等 ,则返回true。8
static boolean equals​(Object[] a, Object[] a2)
如果两个指定的Objects数组彼此 相等 ,则返回 true
static <T> boolean equals​(T[] a, int aFromIndex, int aToIndex, T[] b, int bFromIndex, int bToIndex, Comparator<? super T> cmp)
如果在指定范围内指定的两个Object数组彼此 相等 ,则返回true。
static <T> boolean equals​(T[] a, T[] a2, Comparator<? super T> cmp)
如果两个指定的Objects数组彼此 相等 ,则返回 true
static void fill​(Object[] a, int fromIndex, int toIndex, Object val)
将指定的Object引用分配给指定Object对象的指定范围的每个元素。
static void fill​(Object[] a, Object val)
将指定的Object引用分配给指定的Objects数组的每个元素。8
static int hashCode​(Object[] a)
根据指定数组的内容返回哈希码。
static int mismatch​(Object[] a, int aFromIndex, int aToIndex, Object[] b, int bFromIndex, int bToIndex)
查找并返回指定范围内两个 Object数组之间第一个不匹配的相对索引,否则如果未找到不匹配则返回-1。
static int mismatch​(Object[] a, Object[] b)
查找并返回两个 Object数组之间第一个不匹配的索引,否则如果未找到不匹配则返回-1。
static <T> int mismatch​(T[] a, int aFromIndex, int aToIndex, T[] b, int bFromIndex, int bToIndex, Comparator<? super T> cmp)
查找并返回指定范围内两个 Object数组之间第一个不匹配的相对索引,否则如果未找到不匹配则返回-1。
static <T> int mismatch​(T[] a, T[] b, Comparator<? super T> cmp)
查找并返回两个 Object数组之间第一个不匹配的索引,否则如果未找到不匹配则返回-1。
static <T> void parallelPrefix​(T[] array, int fromIndex, int toIndex, BinaryOperator<T> op)
对于给定的数组子范围执行 parallelPrefix(Object[], BinaryOperator) 。8
static <T> void parallelPrefix​(T[] array, BinaryOperator<T> op)
使用提供的函数并行地累积给定数组的每个元素。
static void parallelSetAll​(double[] array, IntToDoubleFunction generator)
使用提供的生成器函数并行设置指定数组的所有元素以计算每个元素。
static void parallelSetAll​(int[] array, IntUnaryOperator generator)
使用提供的生成器函数并行设置指定数组的所有元素以计算每个元素。
static void parallelSetAll​(long[] array, IntToLongFunction generator)
使用提供的生成器函数并行设置指定数组的所有元素以计算每个元素。
static <T> void parallelSetAll​(T[] array, IntFunction<? extends T> generator)
使用提供的生成器函数并行设置指定数组的所有元素以计算每个元素。
static void parallelSort​(byte[] a)
将指定的数组按升序排序。8
static void parallelSort​(byte[] a, int fromIndex, int toIndex)
将指定的数组范围按数字升序排序。
static <T extends Comparable<? super T>>
void
parallelSort​(T[] a)
根据元素的natural ordering对指定的对象数组按升序排序。
static <T extends Comparable<? super T>>
void
parallelSort​(T[] a, int fromIndex, int toIndex)
根据元素的natural ordering ,将指定对象数组的指定范围按升序排序。
static <T> void parallelSort​(T[] a, int fromIndex, int toIndex, Comparator<? super T> cmp)
根据指定比较器引发的顺序对指定对象数组的指定范围进行排序。
static <T> void parallelSort​(T[] a, Comparator<? super T> cmp)
根据指定比较器引发的顺序对指定的对象数组进行排序。
static void setAll​(double[] array, IntToDoubleFunction generator)
使用提供的生成器函数设置指定数组的所有元素以计算每个元素。
static void setAll​(int[] array, IntUnaryOperator generator)
使用提供的生成器函数设置指定数组的所有元素以计算每个元素。
static void setAll​(long[] array, IntToLongFunction generator)
使用提供的生成器函数设置指定数组的所有元素以计算每个元素。
static <T> void setAll​(T[] array, IntFunction<? extends T> generator)
使用提供的生成器函数设置指定数组的所有元素以计算每个元素。
static void sort​(Object[] a)
根据元素的natural ordering ,将指定的对象数组按升序排序。8
static void sort​(Object[] a, int fromIndex, int toIndex)
根据元素的natural ordering ,将指定对象数组的指定范围按升序排序。
static <T> void sort​(T[] a, int fromIndex, int toIndex, Comparator<? super T> c)
根据指定比较器引发的顺序对指定对象数组的指定范围进行排序。
static <T> void sort​(T[] a, Comparator<? super T> c)
根据指定比较器引发的顺序对指定的对象数组进行排序。
static Spliterator.OfDouble spliterator​(double[] array)
返回覆盖所有指定数组的Spliterator.OfDouble
static Spliterator.OfDouble spliterator​(double[] array, int startInclusive, int endExclusive)
返回覆盖指定数组的指定范围的Spliterator.OfDouble
static Spliterator.OfInt spliterator​(int[] array)
返回覆盖所有指定数组的Spliterator.OfInt
static Spliterator.OfInt spliterator​(int[] array, int startInclusive, int endExclusive)
返回覆盖指定数组的指定范围的Spliterator.OfInt
static Spliterator.OfLong spliterator​(long[] array)
返回覆盖所有指定数组的Spliterator.OfLong
static Spliterator.OfLong spliterator​(long[] array, int startInclusive, int endExclusive)
返回覆盖指定数组的指定范围的Spliterator.OfLong
static <T> Spliterator<T> spliterator​(T[] array)
返回覆盖所有指定数组的Spliterator
static <T> Spliterator<T> spliterator​(T[] array, int startInclusive, int endExclusive)
返回覆盖指定数组的指定范围的Spliterator
static DoubleStream stream​(double[] array)
返回以指定数组作为源的顺序DoubleStream
static DoubleStream stream​(double[] array, int startInclusive, int endExclusive)
返回指定数组的指定范围作为其源的顺序DoubleStream
static IntStream stream​(int[] array)
返回以指定数组作为源的顺序IntStream
static IntStream stream​(int[] array, int startInclusive, int endExclusive)
返回指定数组的指定范围作为其源的顺序IntStream
static LongStream stream​(long[] array)
返回以指定数组作为源的顺序LongStream
static LongStream stream​(long[] array, int startInclusive, int endExclusive)
返回指定数组的指定范围作为其源的顺序LongStream
static <T> Stream<T> stream​(T[] array)
返回以指定数组作为源的顺序Stream
static <T> Stream<T> stream​(T[] array, int startInclusive, int endExclusive)
返回指定数组的指定范围作为其源的顺序Stream
static String toString​(Object[] a)
返回指定数组内容的字符串表示形式。 
 posted on 2021-03-06 20:41  一计  阅读(36)  评论(0)    收藏  举报