stringstream中的东西怎么遍历
1个回答
展开全部
import java.util.ArrayList;
import java.util.Iterator;
public class Test {
public static void main(String[] args) {
ArrayList list = new ArrayList();
list.add(5);
list.add(8);
list.add(9);
//案 推荐 .简洁
for (Integer e : list) {
System.out.print(e + ",");
}
//案二
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
//案三
Iterator it = list.iterator();
while (it.hasNext()) {
System.out.println(it.next());
}
}
}
import java.util.Iterator;
public class Test {
public static void main(String[] args) {
ArrayList list = new ArrayList();
list.add(5);
list.add(8);
list.add(9);
//案 推荐 .简洁
for (Integer e : list) {
System.out.print(e + ",");
}
//案二
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
//案三
Iterator it = list.iterator();
while (it.hasNext()) {
System.out.println(it.next());
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询