public class Test5 {
public static void main(String[] args) {
int [] a1= new int[]{1,2,3};
int [][] a3= new int[][]{{1,3},{2,5},{6,5}};
String[] a4 = new String[]{"a","z","f"};
printObject("a111"+a1);
printObject("a333"+a3);
printObject("a444"+a4);
printObject("xyz");
printObject(new int[]{1,2,3});
}
private static void printObject(Object obj) {
Class arrclass = obj.getClass();
if(arrclass.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);
}
}
}
把a1,a3,a4作为对象传进去,为什么得到的是 数组的哈希值
而new新对象就可 打印出数组 |
|