package DEMO2.DAY11_demo02_arrays; import java.util.Arrays; import java.util.List; public class Demo { public static void main(String[] args) { //获取集合 List list = Arrays.asList(1,2,3,4); System.out.println("将多个数据转成list集合:"+list); //数组排序 int[] arr = {1,6,78,34,99,6,8,8}; System.out.println("排序之前:"+Arrays.toString(arr)); Arrays.sort(arr); System.out.println("排序之后:"+Arrays.toString(arr)); //查找之前数组必须进行排序 int index = Arrays.binarySearch(arr,34); System.out.println("查找到的:"+index); int index2 = Arrays.binarySearch(arr,0,7,6); System.out.println("在区间内查找:"+index2); //数组比较 int[] arr1 = {1,2,3}; int[] arr2 = {1,3,2}; System.out.println("数组是否相等:"+Arrays.equals(arr1,arr2)); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)