迭代器:boolean hasNext() 判断集合中是否还有没有被取出数据
nexe() 取出集合中下一个元素
package
cn.lijun.demo4; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; public class CollectionDemo1 { public static void main(String[] args) { //集合中可以存储任意类型 Collection coll=new ArrayList<>(); coll.add("a"); coll.add("sadsadsa"); //迭代器 获取迭代器 Iterator it=coll.iterator(); while(it.hasNext()){ String s=(String)it.next(); System.out.println(s); System.out.println(s.length()); } } }

 

相关文章:

  • 2022-12-23
  • 2021-10-03
  • 2021-11-21
  • 2022-12-23
  • 2021-05-02
  • 2021-09-29
  • 2022-12-23
猜你喜欢
  • 2021-07-06
  • 2021-09-05
  • 2021-11-03
  • 2021-06-29
  • 2021-11-04
  • 2021-06-29
  • 2022-12-23
相关资源
相似解决方案