Java集合类
| Collection | 对象之间 没有指定的顺序, 允许元素重复。 | |
| Set |
HashSet TreeSet | 对象之间 没有指定的顺序,不允许元素重复。 |
| List |
Arraylist LinkedList | 对象之间 有指定的顺序, 允许元素重复。引入位置下标。 |
| Map |
HashMap TreeMap | 保存关键字和数值的集合 |
Collection
Collection接口 用于表示 任何对象或元素组,它是 LIST和SET的父类。
| boolean add(object element) | 向集合中添加一个对象 |
| boolean remove(object element) | 移除集合中指定元素的单个实例 |
| int size() | 返回此collection中的元素数 |
| boolean isEmpty() | 如果collection无元素,返回true |
| boolean contains(object element) | 如果collection含指定元素返回true |
| iterator iterator() | 返回此collection迭代元素的迭代器 |
| boolean containsAll(collection collection) | 若含所有指定collection元素,true |
| boolean addAll(collection collection) | 添加指定collection元素到此col…中 |
| void clear() | 移除此collection中所有元素 |
| void removeAll(collection collection) | 移除此collection中与指定col中共有的元素 |
| void retainAll(collection collection) | 移除此collection中在指定col中不存在的元素 |
这篇博客主要探讨了Java中的集合类,特别是Collection接口,它是List和Set接口的父接口,用于组织多个对象。内容涵盖了Collection的基本概念及其在Java编程中的应用。
22万+

被折叠的 条评论
为什么被折叠?



