我有一个对象o
,实际上我知道它是某种东西的数组。我如何迭代ȯ
?
Object o;
if (o != null && o.getClass().isArray()) {
for (Object each : o) { // compile error, of course
System.out.println(each);
}
}
您已将该对象转换为数组,然后再遍历该对象。
if (o != null && o.getClass().isArray()) {
Object[] temp (Object[] o)
for (Object each : temp) {
System.out.println(each);
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句