Collection 方法的定义在哪里?
Where will be the definition of Collection methods resides?
我知道Collection是一个包含抽象方法的接口,比如add(), addAll(),..
Collections 是一个 class 包含静态方法,例如 addAll(),max(),.. 它扩展了 Object.
和
Collection 实现接口 Iterable.
接口,因为它只能包含抽象方法,所以只能包含抽象方法(没有定义)。
所以,我的问题是,如果 List、Set、.. 正在实现 Collection 接口,那么像 add()、addAll()、remove()、contains()、iterator()、 .. 写了吗?
List
和 Set
没有实现 Collection
,因为它们也是接口(扩展了 Collection
接口)。
实现在实现中类,如ArrayList
、LinkedList
、HashSet
等...
我知道Collection是一个包含抽象方法的接口,比如add(), addAll(),..
Collections 是一个 class 包含静态方法,例如 addAll(),max(),.. 它扩展了 Object.
和
Collection 实现接口 Iterable.
接口,因为它只能包含抽象方法,所以只能包含抽象方法(没有定义)。
所以,我的问题是,如果 List、Set、.. 正在实现 Collection 接口,那么像 add()、addAll()、remove()、contains()、iterator()、 .. 写了吗?
List
和 Set
没有实现 Collection
,因为它们也是接口(扩展了 Collection
接口)。
实现在实现中类,如ArrayList
、LinkedList
、HashSet
等...