java中odds(a)的意思,Java当中Collection和Collections有什么区别?

Java当中Collection和Collections有什么区别?

Collection 即 java.util.Collection

Collection 是一个集合接口。它提供了对集合对象进行基本操作的通用接口方法。

Collection接口的意义是为各种具体的集合提供了最大化的统一操作方式。

* The root interface in the collection hierarchy. A collection

* represents a group of objects, known as its elements. Some

* collections allow duplicate elements and others do not. Some are ordered

* and others unordered. The JDK does not provide any direct

* implementations of this interface: it provides implementations of more

* specific subinterfaces like Set and List. This interface

* is typically used to pass collections around and manipulate them where

* maximum generality is desired.

是集合层次结构的根接口。一个集合表示一组被称为elements的对象。一些集合允许重复元素,一些不允许。有的是有序的,有些是无序的。JDK不提供任何直接的这个接口的实现,他提供了特定子接口的实现,例如Set,List。这个接口通常用于传递集合和操作结合,在需要最大的通用性的时候。

根据这一段源码前的注释可以看出,集合是类似于list,set,queue的父接口。

引用一张来自https://blog.csdn.net/javaee_gao/article/details/96372530的图片

5eb2a6c0acc0017fe17047bfcd6fe9fc.png

很好的说明了Collection的衍生。

Collections 即 java.util.Collections

他是一个包装类,包含了有关集合操作的静态方法。不能被实例化,就像一个工具类一样

* This class consists exclusively of static methods that operate on or return

* collections. It contains polymorphic algorithms that operate on

* collections, "wrappers", which return a new collection backed by a

* specified collection, and a few other odds and ends.

这个类之包含一些静态方法或者返回集合。他包含像武器一样对付集合的多态算法,该算法返回特定的新集合,以及一些其他的东西。

从上面两段话我们可以明显的看出两者的区别,collection是一个接口,之后的set,queue,list都是基于这个接口实现的。collections是一个工具类,用于帮助我们处理集合

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值