码迷,mamicode.com
首页 > 编程语言 > 详细

Java集合 - Collection

时间:2016-03-16 22:43:56      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:

Ref:http://blog.csdn.net/liulin_good/article/details/6213815

    http://www.cnblogs.com/averey/p/4306166.html

一、java.util.Iterator<E>接口

  迭代器

技术分享
 1 package java.util;
 2 
 3 public interface Iterator<E>{
 4     // Return true iteration has more elements
 5     boolean hasNext();
 6 
 7     // Return the next element in the iteration
 8     E next();
 9 
10     // Remove the last element returned by this iterator. This method can be called only once per call to next
11     void remove();
12 }
View Code

 

二、java.util.Collection接口

   继承java.lang.Iterable接口,包含iterator()方法返回Iterator<T>

技术分享
 1 package java.util;
 2 
 3 public interface Collection<E> extends Iterable<E>{
 4     
 5     int size();
 6     
 7     boolean isEmpty();
 8     
 9     boolean contains(Object o);
10     
11     Iterator<E> iterator();
12     
13     Object[] toArray();
14     
15     // <T>:申明T为泛型。参考:http://www.zhihu.com/question/31967519
16     <T> T[] toArray(T[] a);
17     
18     boolean add(E e);
19     
20     boolean remove(Object o);
21     
22     //Collection<?>:未知Collection,该Collection的元素类型可以匹配任意类型
23     boolean containsAll(Collection<?> c);
24     
25     boolean addAll(Collection<? extends E> c);
26     
27     boolean removeAll(Collection<?> c);
28     
29     //保留该集合中在目标集合中的元素
30     boolean retainAll(Collection<?> c);
31     
32     void clear();
33     
34     boolean equals(Object o);
35     
36     int hashCode()
37 }
View Code

技术分享

 

三、Collection类型层次

技术分享

 

Java集合 - Collection

标签:

原文地址:http://www.cnblogs.com/iszer/p/5285009.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!