List Interface:
One: ArrayListprivate static final int default_capacity = 10;private static final object[] Empty_elementdata = {};private transient object[] elementdata;private int size;Use arrays to store elements, that is, based onobject[] To manage the element, equal to the enhanced version of the array, call the Ensurecapacityinternal () method on the Add () method to expand the capacity.
Two:linkedlist: linkedlist<e> extends abstractsequentiallist<e> implements List<e>, Deque<e , cloneable Implements the Deque,cloneable interface: the ability to replicate and have a queue inherits the Abstractsequentiallist abstract class, while Abstractsequentiallist inherits the Abstactlist abstract class transient int size = 0;transient node<e> first;transient node<e> last;Has two properties: First,last, which represents the first and last. node is used to represent each element. Node is an internal static class private static classes node<e> {E item; Node<e> Next; Node<e> prev; Node (node<e> prev, E element, node<e> next) {This.item = element; This.next = Next; This.prev = prev; Each node, in addition to itself, has a reference to the front and back elements, allthe Inkedlist class is a two-way list.Operation:private void Linkfirst (e e)Private Linklast (e e)Features: Fast insertion through linked lists, but slow access to elementswhile Arraylist.get () is faster, set () is relatively slow
set Interface:1: Features:A collection that contains no duplicate elements. More formally, sets contain no pair of elements E1 and E2such thate1.equals (E2), and at the most one null element:This means that we can use the set interface to store non-empty, not repeating to the element.
Common classes: HashSet and TreeSet
1:hashset: Unordered collection, support null value, using hash algorithm to store elements.
hashset<e> extends abstractset<e> implements Set<e>, cloneable
Private transient hashmap<e,object> map:
Features:1: Use HashMap key to store the collection2: Non-thread safe: To improve efficiency without using synchronized, an external lock must be used if the multithreaded operation is a hashset. 3: Gets the element to return an iterator through iterator (), so it has the Fail-fast attribute: Fail-fast is when iterating over the collection, if a thread modifies the collection, then a fail-fast error occurs.
TreeSet class: Is an ordered set, does not support null values, using binary tree implementation of sortingTreeset<e> extends abstractset<e> implements Navigableset<e>, Cloneable, Java.io.Serializable private transient navigablemap<e,object> m; private static Final Object PRESENT = new Object (); inherits the Navigableset interface, uses the NAVIGABLEMAP to store the element, actually is treemap to store the element, if you to the TreeMap comparison understanding, to TreeSet also has no problemFeatures:1: Use TreeMap key to store the element,1: Support sort: Final comparator<? Super K> Comparator, there is a Comparator sort instance, when put (), the Compare () is called first2: Non-thread-safe, requires an external lock to ensure thread safety. Summary: The 1:arraylist is suitable for fast reading, with fewer modifications than the set of operations. The 2:linkedlist is suitable for more than a set of modified operations, with fewer reads. The 3:hashset is suitable for storing non-empty, non-repeating, unordered collection elements with high efficiency. 4:treeset is suitable for storing non-empty, non-repeating ordered set elements, which are less efficient than hashset.
Java enterprise-Class generic rights security framework source SPRINGMVC MyBatis or Hibernate+ehcache Shiro Druid Bootstrap HTML5
"Java Framework source code download"
Introduction to Java Collection common classes