System.out.println(“object[”+i+“]:”+object[i]);
}
}
flag = true;
return flag;
}
mian方法测试:
public static void main(String[] args) {
CommentUtils utils = new CommentUtils();
String s = “爱因斯坦”;
Integer i = 1000;
double dd = 4502.434D;
int[] in = {1,3,4,5,6};
int[][] num = { {1,2,3},{4,5,6},{7,8,9}};
User user = new User(“银河系”,“新东方”);
String[] str = {“松岛枫”,“回防高地”};
List arr = new ArrayList();
Collections.addAll(arr,i,s,in,dd,in,num,str,user);
utils.printArrays(i,s,in,dd,in,num,str,user,arr);
}
测试结果:
可以看到,传递的参数可以是基本数据类型、一位数组和二维数组以及对象都可以依次打印出来!