遍历对象

米兰

我有一个对象o,实际上我知道它是某种东西的数组。我如何迭代ȯ

Object o;
if (o != null && o.getClass().isArray()) {
  for (Object each : o) {  // compile error, of course
    System.out.println(each);
  }
}
阿比玛兰·库格萨桑(Abimaran Kugathasan)

您已将该对象转换为数组,然后再遍历该对象。

if (o != null && o.getClass().isArray()) {
  Object[] temp (Object[] o)
  for (Object each : temp) {  
    System.out.println(each);
  }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章