java collections读书笔记(9)collection框架总览(2)

本文详细介绍了Java集合框架中的collection接口及Iterator接口的相关方法。包括添加、删除、查询元素等操作,并对比了新旧迭代器接口的区别。

框架算法:

1)collection接口

add()  Adds an element to the collection.
addAll()  Adds a collection of elements to the collection.
clear()  Clears all elements from the collection.
contains()  Checks if a collection contains an element.
containsAll()  Checks if a collection contains a collection of elements.
equals()  Checks for equality with another object.
hashCode()  Returns the computed hash code for the collection

isEmpty()  Checks if a collection is empty.
iterator()  Returns an object from the collection that allows all of the collection's elements to be visited.
remove()  Clears a specific element from collection.
removeAll()  Clears a collection of elements from the collection.
retainAll()  Removes all elements from the collection not in another collection.
size()  Returns the number of elements in the collection.
toArray()  Returns the elements of a collection as an array.

Iterator接口:

interator接口是collection框架用来代替老的Enumeration接口的。

提供了在collection中遍历元素的一个标准方式。

hasNext()  Checks for more elements in the iterator.
next()  Fetches the next element of the iterator.
remove() Removes an element from the iterator.

转载于:https://www.cnblogs.com/aomi/p/3141485.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值