Java集合之面试篇
来源:互联网 发布:网络实名制 郭德纲 编辑:程序博客网 时间:2024/03/29 14:58
鉴于Android面试中对java基础很是看中而集合又是基础中的核心部分,所以有必要好好学习下集合的相关知识,这篇博客的原则如下
不分析任何源码方法,只看源码注释
Iterable
public interface Iterable<T>{}Implementing this interface allows an object to be the target of the "for-each loop" statement(通过实现这个接口允许一个对象成为foreach循环语句的目标)
Collection
public interface Collection<E> extends Iterable<E> {}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> (代表一组对象,为人所知的是他的元素集,一些集合允许重复的元素,另外一些不允许,一些是有顺序的而另外一些是无序的,JDK不提供这个接口的直接实现,他提供更多子接口(比如List和Set)实现)
List
public interface List<E> extends Collection<E> {}An ordered collection (also known as a <i>sequence</i>)(有序集合)Unlike sets, lists typically allow duplicate elements(与Set不同,List允许重复的元素)
Set
public interface Set<E> extends Collection<E> {}A collection that contains no duplicate elements.(不包含重复的集合)
ArrayList
public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable{}Resizable-array implementation of the <tt>List</tt> interface(实现List接口的长度可变数组)Note that this implementation is not synchronized.(线程不安全)
LinkedList
public class LinkedList<E> extends AbstractSequentialList<E> implements List<E>, Deque<E>, Cloneable, java.io.Serializable{} Doubly-linked list implementation of the {@code List} and {@code Deque} interfaces(List和Deque的双链表实现)Note that this implementation is not synchronized.(这个类不是线程安全的)
Vector
public class Vector<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable{}The {@code Vector} class implements a growable array of objects (数组对象长度可变)几乎等同于ArrayList但是这个类在方法名前声明了“synchronized”,所以是线程安全的
关于HashMap和HashTable的介绍请看我的这篇博客
HashMap和HashTable
HashSet
public class HashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable, java.io.Serializable{}This class implements the <tt>Set</tt> interface, backed by a hash table (actually a <tt>HashMap</tt> instance).(很明显 HashSet就是建立在HashMap的基础上)Note that this implementation is not synchronized.(线程不安全)
TreeMap
A Red-Black tree based {@link NavigableMap} implementation.(红黑树)
阅读全文
0 0
- Java集合之面试篇
- java面试之集合类
- 面试笔试之Java集合
- java面试之集合类
- 赢在面试之Java集合框架篇(3)
- 赢在面试之Java集合框架篇
- 【java面试】集合类篇
- [置顶] java面试必备之集合类
- Java找工作之面试复习(1) 集合
- Java面试准备之集合框架
- Java面试准备之集合框架
- Java基础面试之集合框架
- JAVA面试之集合框架(三)
- 【JAVA秒会技术之秒杀面试官】秒杀Java面试官——集合篇(一)
- 面试之-集合
- 面试之集合
- java集合类面试
- java集合框架面试
- vector清空
- 在OpenSUSE42.3里面安装MongoDB
- WIN+Anaconda(python3.6)+Face_recognition安装
- LightOJ
- 模拟strncmp( )函数
- Java集合之面试篇
- windbg调试命令
- FZU
- IntelliJ IDEA 源值1.5已过时,将在未来所有版本中删除
- JavaScript执行机制
- 初用vue2写一个超简陋知乎日报(不与知乎日报api交互)超详细记录
- webRTCTutorial 项目文档目录
- HTTP/2 之服务器推送 (Server Push) 最佳实践
- oj__小题B,C