集合的父子类关系

 

一.Collection的父子类关系
1.Iterable(java集合的顶级接口之一)——实现此接口的类可以使用新的for循环

2.Iterator(接口,遍历器)ListIterator
方法:hasNext();next();remove();

3.Collection(接口,继承Iterable)
方法:
add();addAll();remove();removeAll();contains();containsAll();
size();isEmpty();toArray();clear();iterator();

4.AbstractCollection(抽象类,继承Collection并重写实现里面的方法)

二.List的父子类关系
1.List(接口,继承Collection并包含里面的所有方法)——可重复,并且有序
方法(可以通过下标操作元素):
get(i);set(i,p);add(i,p);remove(i);
indexOf(p);lastIndexOf();subList(i,j);

2.工具类Collections——为List提供排序方法
sort(list);——返回值int型
Collections.sort(list,new Comparator<String>() {
public int compare(String o1,String o2) {
return o1.length()-o2.length();
}
});

3.AbstractList(抽象类,实现接口List并重写实现里面的方法,继承AbstractCollection)

4.ArrayList(类,继承AbstractList并重写实现里面的方法)

三.队列Queue的父子类关系——遵循“先进先出”原则
1.Queue(接口,继承Collection)
方法:
offer(p);poll();peek();

2.AbstractSequentialList(抽象类,继承AbstractList)

3.LinkedList(类,继承AbstractSequentialList)

四.双端队列Deque的父子类关系
1.Deque(接口,继承Queue并重写实现里面的方法)
方法:
offerFirst()——push()——入栈;pollFirst()——pop()——出栈;
offerLast();pollLast();
peekFirst();peekLast();

2.AbstractSequentialList(抽象类,继承AbstractList)

3.LinkedList(类,继承AbstractSequentialList)

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

linsa_pursuer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值