Java基础学习笔记之七(4)--Iterator&Comparable

***Iterator 接口  

  Iterator对象称作迭代器用以方便的实现对容器内元素的
遍历操作。  
  1.boolean hasNext()
  Returns true if the iteration has more elements.
  如果迭代器中还有元素可以迭代,则返回true
  (判断游标右边是否还有元素可以迭代)
  
  2.E next()
  Return the next element in the iteration.
  返回迭代的下一个元素
  (返回游标右边的元素,并将游标移动到下一个位置)
  
  3.void remove()
  Removes from the underlying collection the last element
return by the iteration.
  删除从迭代器中指向的当前元素
  (iterator对象的remove方法是在迭代过程中删除元素的
唯一安全的方法)

***Comparable 接口

  所有需要排序的类,都需要实现java.lang.Comparable接口。
重写compareTo方法。
  1.public int compareTo(T obj);
  Compares this object with the specified object for order.  
  比较此对象与指定对象的顺序
  
  返回0表示    this==obj
  返回正数表示 this>obj
  返回负数表示 this<obj
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值