Collection集合
开发中在使用集合存储数据时,会有不同的存储需求,但都具有共性的功能:比如:增、删、改、查(CRUD),java中最基本的规律抽取到了一个接口中
java.util.Collection
常用的一些方法:
-
public boolean add(E e): 把给定的对象添加到当前集合中 。 -
public void clear():清空集合中所有的元素。 -
public boolean remove(E e): 把给定的对象在当前集合中删除。 -
public boolean contains(E e): 判断当前集合中是否包含给定的对象。 -
public boolean isEmpty(): 判断当前集合是否为空。 -
public int size(): 返回集合中元素的个数。 -
public Object[] toArray(): 把集合中的元素,存储到数组中。可以间接对集合进行遍历。