|
Collection的功能 (1)Collection的功能(自己补齐中文意思) 1、添加功能 boolean add(Object obj):向集合中添加一个元素。 boolean addAll(Collection c):向集合中添加一个集合的元素。 2、删除功能 void clear():删除集合中所有的元素。 boolean remove(Object obj):删除集合中指定的元素。 boolean removeAll(Collection c):删除集合中指定的集合元素。 3、判断功能 boolean isEmpty():判断集合是否为空。 boolean contains(Object obj):判断集合是否包含指定的元素。 boolean containsAll(Collection c):判断集合是否包含指定的集合中的元素。 4、遍历功能 Iterator iterator():迭代器。 hasNext():判断是否还有元素 next():获取下一个元素 5、长度功能 int size():获得集合的元素个数。 6、交集功能 boolean retainAll(Collection c):判断集合中是否有相同的元素。 7、转换功能 Object[] toArray():把集合变成数组。
|