本文共 1119 字,大约阅读时间需要 3 分钟。
Modifier and Type | Method and Description |
---|---|
static <T> <T> | (T... a) Returns a fixed-size list backed by the specified array. |
应用:
1 ListintList = Arrays.asList(1, 2, 3, 4);
static int | (int[] a, int fromIndex, int toIndex, int key) Searches a range of the specified array of ints for the specified value using the binary search algorithm |
应用:
1 //fromIndex,toIndex这两个参数可以省略(表示整个数组) 2 //不省略表示在这个区间查找,左闭右开, key 表示要查找的元素 3 //返回要查找元素的 索引位置 4 int index = Arrays.binarySearch(new int[] { 1, 2, 3, 4, 5, 6, 7 }, 3); 5 public static int binarySearch(byte[] a, int fromIndex, int toIndex, byte key)
1 int[] a ={1,2,3,4,5};2 int[] b =Arrays.copyOf(a, 2); //1 2 3 4 int[] c = Arrays.copyOfRange(a, 0, 3); //左闭合右开 1 2 3
1 int[] a ={7,2,5,4,3};2 Arrays.sort(a); //2 3 4 5 7
Arrays.sort(a, fromIndex, toIndex); 可以指定数组排序的开始和结束的位置 (左闭右合)
1 int[] a ={7,2,5,4,3};2 int[] b = {1,2,3}3 System.out.println(a.equals(b)); //false
转载地址:http://mdnbz.baihongyu.com/