a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 156|回复: 0

[基础知识] JAVA基础:Iterator迭代得到list中的数值

[复制链接]
发表于 2012-8-4 12:37:27 | 显示全部楼层 |阅读模式
Iterator迭代可以获得list中的数值。   Iterator  iterator  =  list.iterator() ;
9 e0 A: Q  {+ R! c  While( iterator.hasNext()){
. c7 I/ o4 y' v5 z' ]8 `/ @( a( c  String XX=(String)iterator.next();2 @  d" ]: c" M% i$ R  d
  }6 R% h# ]* Z' [6 x) z
  注重在while轮回中必然要有iterator.next();且只能呈现一次,必需有是因为只有.next()才能获得下一条数据,否则进入死轮回,只能有一次是因为,呈现一次获得吓一跳记实,如不美观同时呈现两次,则是在以此轮回中获得了两个数据。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-4-29 22:31 , Processed in 0.198424 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表