在使用
Java
的时候,我们都会遇到使用集合(
Collection
)的时候,但是
Java API
提供了多种集合的实现,我在使用和面试的时候频频遇到这样的
“
抉择
”
。
:
)(主要还是面试的时候)
久而久之,也就有了一点点的心得体会,写出来以供大家讨论 。
总的说来, Java API 中所用的集合类,都是实现了 Collection 接口,他的一个类继承结构如下:
Collection<--List<--Vector
Collection<--List<--ArrayList
Collection<--List<--LinkedList
Collection<--Set<--HashSet
Collection<--Set<--HashSet<--LinkedHashSet
Collection<--Set<
久而久之,也就有了一点点的心得体会,写出来以供大家讨论 。
总的说来, Java API 中所用的集合类,都是实现了 Collection 接口,他的一个类继承结构如下:
Collection<--List<--Vector
Collection<--List<--ArrayList
Collection<--List<--LinkedList
Collection<--Set<--HashSet
Collection<--Set<--HashSet<--LinkedHashSet
Collection<--Set<