首页 > 编程语言 > 详细

Java集合 - Collection

时间:2016-03-16 22:42:28      阅读:329      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!