数组的反射
2014-10-27 23:13
85 查看
所有类型相同,维度相同的数组都属于同一段字节码,同一种类型
package com.best.array; public class TestArray { /** 所有类型相同,维度相同的数组都属于同一段字节码,同一种类型 **/ public static void main(String[] args) { int [] a1 = new int[3]; int [] a2 = new int[4]; int[][] a3 = new int[2][3]; int[][] a4 = new int[4][4]; System.out.println(a1.getClass() == a2.getClass()); System.out.println(a3.getClass() == a4.getClass()); /** "["-代表数组,"I"--代表整数,预期输出:[I **/ System.out.println(a1.getClass().getName()); /** "["-代表数组,"I"--代表整数,预期输出:[[I **/ System.out.println(a3.getClass().getName()); } }
输出:
true true [I [[I
中括号:代表数组,I--代表整数类型,可以参考API文档反射的getName方法描述
相关文章推荐
- 使用反射编写泛型数组代码
- 通过反射取得数组信息并修改数组内容
- 反射获取属性数组为空,一个大大的坑。。。
- 黑马程序员--03.反射--06【数组的数据类型】【数组数据类型的父类】
- 数组的反射
- 数组集合+反射
- 黑马程序员-关于数组和集合的反射
- Java反射之调用构造方法and操作数组
- 反射的使用---操作数组
- JAVA进阶之旅(二)——认识Class类,反射的概念,Constructor,Field,Method,反射Main方法,数组的反射和实践
- 跟王老师学反射(八):使用反射操作数组
- java反射编写泛型数组代码
- java反射实现动态扩建数组
- 实例讲解Java编程中数组反射的使用方法
- 序列化,反序列化,可变数组,反射,注解 元注解---了解
- C#反射取数组单个元素的类型
- JAVA 反射创建数组和操作数组的意义
- 通过反射修改数组大小
- java反射——操作数组
- 对接收数组参数的成员方法进行反射——Method的一个demo