遍历的多实战写法
1.用 Interator遍历
List<Person> personsList = ReadXmlByPullService.ReadXmlByPull(inputStream);
Log.e("abc", personsList.get(0).getName());
for (Iterator iterator = personsList.iterator(); iterator.hasNext(); ) {
Person person = (Person) iterator.next();
Log.i(PERSONSTRING, person.toString());
}
2.项目中用到的高级写法
for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext(); ) {
StringBuffer sb = new StringBuffer();
String key = iterator.next();
sb.append("[").append(key).append("]");
for (int k = map.get(key); k < 4; k++) {// 初使化;循环体;循环条件
sb.append(k + ",");
}
}