Collection和Collections有什么区别

参考答案

Collection 定义了集合类的基本方法,是JDK中集合层次结构中的最根本的接口。

源码中的解释:

* The root interface in the <i>collection hierarchy</i>.  A collection
* represents a group of objects, known as its <i>elements</i>.  Some
* collections allow duplicate elements and others do not.  Some are ordered
* and others unordered.  The JDK does not provide any <i>direct</i>
* implementations of this interface: it provides implementations of more
* specific subinterfaces like <tt>Set</tt> and <tt>List</tt>.  This interface
* is typically used to pass collections around and manipulate them where
* maximum generality is desired.

Collections 是一个包装类。

它包含了各种有关集合操作的静态多态方法,不能实例化,Collection 集合框架的工具类。

* 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.

以上,是Java面试题【Collection和Collections有什么区别】的参考答案。

 

输出,是最好的学习方法。

欢迎在评论区留下你的问题、笔记或知识点补充~

—end—

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧