当前位置:网站首页>2.Collection接口
2.Collection接口
2022-08-09 09:23:00 【过来我的小熊】
Java Collection接口
Collection体系集合
graph TD;
Interface.Collection-->Interface.List
Interface.Collection-->Interface.Set
Interface.List-->Class.ArrayList
Interface.List-->Class.LinkedList
Interface.List-->Class.Vector
Interface.Set-->Class.HashSet
Interface.Set-->Interface.SortedSet
Interface.SortedSet-->Class.TreeSet
Interface(接口),Class(实现类)
该体系结构的根接口,代表一组对象,称为"集合"(Interface.Collection)
List接口的特点:有序,由下标,元素可重复
Set接口的特点:无序,无下标,元素不能重复
Collection父接口
特点:代表一组任意类型的对象,无序,无下标,不能重复
方法:
- boolean add(Object obj) 添加一个对象
- boolean addAll(Collection c) 将一个集合中的所有对象添加到此集合中
- void clear() 清空此集合中的所有对象
- boolean contains(Object o) 检查此集合中是否包含o对象
- boolean equals(Object o) 比较此集合是否与指定对象相等
- boolean isEmpty() 判断此集合是否为空
- boolean remove(Object o) 在此集合中移除o对象
- int size() 返回此集合中的元素个数
- Object[] toArray() 将此集合转换成数组
- iterator() 返回在此集合的元素上进行迭代的迭代器
- hasNext() 判断是否存在下一个元素,返回boolean值
- next() 获取下一个元素
- remove() 删除当前元素
- 不能同时使用collecton方法 ConcurrentModificationException 并发修改异常
边栏推荐
猜你喜欢
随机推荐
初窥门径代码起手,Go lang1.18入门精炼教程,由白丁入鸿儒,首次运行golang程序EP01
全球19级谷歌卫星地图免费查看下载
Anti App so层对抗分析
Summary of steps and methods for installing and uninstalling test cases that you must read
性能测试的基本概念是什么?做好性能测试需要掌握哪些知识?
"The camera can't be used" + win8.1 + DELL + external camera + USB drive-free solution
A first look at the code to start, Go lang1.18 introductory refining tutorial, from Bai Ding to Hongru, the first time to run the golang program EP01
年薪40W测试工程师成长之路,你在哪个阶段?
JS报错-Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on...
选择黑盒测试用例设计方法的综合策略方案总结
米斗APP逆向分析
JMeter初探五-配置元件与参数化
功能自动化测试实施的原则以及方法有哪些?
软件测试分析流程及输出项包括哪些内容?
使用Protege4和CO-ODE工具构建OWL本体的实用指南-1.3版本(7.4 Annotation Properties-注释属性)
本体开发日记05-努力理解SWRL(Built-Ins)
测试计划包括哪些内容?目的和意义是什么?
Ovie map computer terminal and mobile terminal can not be used, is there any alternative map tool
运行flutter项目时遇到的问题
TestNG使用教程详解