I. Summary OF collection classes
1. Arrays and collections
Arrays: You can store both basic data Types and similar objects . Fixed length.
Collection: only objects can be stored, and categories may be different . The length is not fixed.
Collection is the root interface of the collection class, which is inherited to produce two interfaces,set , and List.
The Set cannot contain duplicate elements. A list is an ordered collection that can contain duplicate elements that provide a way to access by index .
Map is another interface in the Java.util package that is not related to the collection interface and is independent of each other, but is part of the collection class. Map contains the key-value pair . A map cannot contain duplicate keys, but it can contain the same value.
Iterator, all of the collection classes implement the Iterator interface, which is an interface for iterating through the elements in the collection, which consists of the following three ways:
1.hasNext () whether there is a next element.
2.next () returns the next element.
3.remove () deletes the current element.
ArrayList and LinkedList:
1.ArrayList is the realization of the data structure based on dynamic array, LinkedList data structure based on linked list.
ArrayList important data Structures (arrays):
1.1. // save an array of data in ArrayList private transient object[] elementdata;
1.2. // ArrayList the number of actual data in the private int size;
Linklist important data structures (two-way loop linked list):
Private transient entry<e> Header = new entry<e> (null, NULL, NULL); Linked list nodes
private transient int size = 0; Number of nodes
2. For random access get and set,arraylist better than LinkedList, because linklist to move the pointer.
3. Add and Remove,linklist are the dominant for new and deleted operations because ArrayList is moving the data.
Java Fundamentals 2