collection是单列集合,是一个接口,单列集合的顶层父接口。
常用方法
add方法
如果往set系列方法里面添加数据,已经存在返回false。
collection co=new ArrayList(); co.add(添加的元素)
clear方法
清空集合内容
collection co=new ArrayList(); co.clear();
remove方法
删除元素
collection co=new ArrayList(); co.remove(要删除的元素);
cotains方法
collection co=new ArrayList(); co.clear(查询元素);
底层是equals方法,所以需要javabean需要重写equals方法
isEmpty方法
collection co=new ArrayList(); co.isEmpty();//返回值为布尔类型
判断集合是否为空
size方法
collection co=new ArrayList(); co.size();
返回值为集合长度