【发布时间】:2014-01-01 15:24:16
【问题描述】:
我想遍历对象数组列表中的项目,以及索引,以便我可以将字符串(对象/类的一部分)传输到ArrayList<String>
我的代码:
for(PeopleDetails person : people_list; /*not using termination, will terminate at end of people_list */ ;i++){
/// Code here
}
但是我得到一个错误,说:
Type mismatch: cannot convert from ArrayList<PeopleDetails> to PeopleDetails.
是什么导致了这个错误? 感谢您的帮助!
【问题讨论】:
-
它告诉你
people_list是ArrayList而不是PeopleDetails。 -
你是如何声明你的
ArrayList的? -
尝试发布更多相关的代码,如数量明智。另外,为什么不使用普通的 for 循环而不是 增强的 循环呢?
标签: java android loops arraylist