黑马程序员技术交流社区

标题: Collection与Collections的区别 [打印本页]

作者: 垂天云    时间: 2013-9-8 14:59
标题: Collection与Collections的区别
本帖最后由 垂天云 于 2013-9-8 16:32 编辑

JAVA 集合中,谁能够详细说一下Collection与Collections的区别?

谢谢了!

作者: ★忙碌★    时间: 2013-9-8 15:30
Collection是集合类的上级接口,继承与他的接口主要有Set 和List.
Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。
作者: 李锡碧    时间: 2013-9-8 15:41
看看文档,可以知道的。呵呵{:soso_e130:}
public class Collections extends Object
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.
这个类由专门的静态方法,处理或返回集合。它包含了多态算法操作集合,“包装”,它返回一个新的集合由指定的收集,和其他一些东西。
(Collections 操作集合类的工具类)

public interface Collection<E> extends Iterable<E>
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.
根接口集合中的层次结构。一个集合代表一组对象,称为它的元素。一些集合允许重复的元素,而其他人则没有。有些是命令和其他无序。JDK并不提供任何直接的实现这个接口:它提供了实现更多的具体设置和列表,个子像这个接口通常是用来传递集合和操纵它们周围,最大共性,是理想的。
(Collection是集合类的接口)


作者: 张云飞    时间: 2013-9-8 15:57
简单的说,
1、Collection 是一个集合接口。它提供了对集合对象进行基本操作的通用接口方法。Collection接口在Java 类库中有很多具体的实现。Collection接口的意义是为各种具体的集合提供了最大化的统一操作方式。
2、Collections 是一个包装类。它包含有各种有关集合操作的静态多态方法。此类不能实例化,就像一个工具类,服务于Java的Collection框架。

作者: hmwudizl91zl    时间: 2013-9-8 17:26
Collections是个java.util下的类,它包含有各种有关集合操作的静态方法。
Collection是个java.util下的接口,它是各种集合结构的父接口。




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2