java数组倒序

public static void main(String[] args) {
        System.out.println("use Collections.reverse() method");

        String[] strings = { "atao", "bpang", "cqu", "dxin" };
        System.out.println("\t" + Arrays.toString(strings));
        // 这种方式仅针对引用类型,对于基本类型如:
        // char[] cs = {'a','b','c','g','d'};
        // 应该定义或转换成对应的引用类型:
        Character[] cs = {'a','b','c','g','d'};
       System.out.println(Arrays.toString(cs));
       Integer[] arr = {1,2,3};
       System.out.println(Arrays.toString(arr));
        Collections.reverse(Arrays.asList(strings));
        Collections.reverse(Arrays.asList(cs));
        Collections.reverse(Arrays.asList(arr));
        System.out.println(Arrays.toString(arr));
        System.out.println("\t" + Arrays.toString(strings));
        System.out.println(Arrays.toString(cs));
    }
java数组倒序_第1张图片

你可能感兴趣的:(自学)