//下标 for(int i = 0 ; i< list.size();i++){ System.out.println(list.get(i)); } //for- each for(Object o:list){ System.out.println(o); } //迭代器 Iterator it = list.iterator(); while(it.hasNext()){ System.out.println(it.next()); } //Object数组 Object o[]; o = list.toArray(); for(int i = 0 ; i <o.length;i++){ System.out.println(o[i]); } 结果:[a,b,c,d] 替换[ ] o.toString().replaceAll("\\[", "").replaceAll("\\]", "")
遍历集合List
最新推荐文章于 2021-06-05 01:23:47 发布