关键字: Iterator(迭代器)
<%
List obj = (List)request.getAttribute("redate");
//System.out.println("obj.size()======================="+obj.size());
Iterator it = obj.iterator();
//System.out.println("it================"+it);
while(it.hasNext()){
Object obje = it.next();
//System.out.println(obje);
TB_REBBSBUSINESS tb_rebbs = (TB_REBBSBUSINESS)obje;
//System.out.println("tb_rebbs==========="+tb_rebbs);
//System.out.println(tb_rebbs.getRETITLE());
%>
List obj = (List)request.getAttribute("redate");
//System.out.println("obj.size()======================="+obj.size());
Iterator it = obj.iterator();
//System.out.println("it================"+it);
while(it.hasNext()){
Object obje = it.next();
//System.out.println(obje);
TB_REBBSBUSINESS tb_rebbs = (TB_REBBSBUSINESS)obje;
//System.out.println("tb_rebbs==========="+tb_rebbs);
//System.out.println(tb_rebbs.getRETITLE());
%>
<%=tb_rebbs.getRECONTENT()%>
<%
}
%>
}
%>
本文介绍了一种使用Java Iterator(迭代器)来遍历List集合的方法。通过获取List对象的迭代器并利用hasNext和next方法,可以有效地访问集合中的每一个元素。这种方式不仅能够确保按顺序访问每个元素,还提供了灵活的控制流程。
3382

被折叠的 条评论
为什么被折叠?



