反射认识_05_数组反射_打印
package ReflectionMethod; import java.lang.reflect.Array; public class ReflectionArrayPrint { public static void main(String[] args) { int[] a=new int[]{1,2,3}; printArray(a); } public static void printArray(Object obj) { Class cl=obj.getClass(); if(cl.isArray()){ int len=Array.getLength(obj); for(int i=0;i<len;i++){ System.out.println(Array.get(obj, i)); } }else { System.out.println(obj); } } }