zoukankan      html  css  js  c++  java
  • 反射_6各种数组的反射类型比较

    int[] a1 = new int[3];// 一维数组
    int[] a2 = new int[4];// 一维数组
    int[][] a3 = new int[3][3];// 二维数组
    String[] a4 = new String[3];// 字符串数组
    Object[] a5 = new Object[3];// Object数组
    // 同为int[],大小不一样比较:true
    System.out.println(a1.getClass() == a2.getClass());
    // 不同维度的数组比较:直接编译不通过
    System.out.println(a1.getClass()==a3.getClass());
    // String[] 和 int[]比较:直接编译不通过
    System.out.println(a1.getClass()==a4.getClass());
    // Object[]和String[]比较:false
    System.out.println(a4.getClass() == a5.getClass());
    // String数组的父类和Object数组的父类比较:false--->class java.lang.Object!=class [Ljava.lang.Object;
    System.out.println(a4.getClass().getSuperclass() == a5.getClass());
  • 相关阅读:
    centos 7 安装maven
    linux添加用户
    intellij添加jar包
    mysql用户管理
    centos7 mariaDB安装
    hibernate入门实例
    Linux文件描述符
    Python小爬虫实例
    IO流-文件管理
    IO流-ZIP文档
  • 原文地址:https://www.cnblogs.com/dingjm01/p/8334523.html
Copyright © 2011-2022 走看看