Road of big data week01 - summed up a set of terms day02_2

(First draft was too late, tomorrow, to be supplemented)

1, an array of objects (master)

  (1) an array of basic data types may be stored, it may be stored reference type. It stores the object reference type is called an array of arrays of time.

  (2) Case:

    5 students with an array of storage objects, and through the array.

 1 package day02;
 2 
 3 /** 
 4 * @author WYH
 5 * @version 2019年11月12日 下午10:28:33
 6 */
 7 public class test {
 8     public static void main(String[] args) {
 9         Students[] s = new Students[2];
10         
11         Students s1 = new Students("xiao",21);
12         Students s2 = new Students("da",22);
13         
14         s[0] = s1;
15         s[1] = s2;
16         
17         for(int i = 0;i<s.length;i++) {
18             System.out.println(s[i]);
19         }
20         
21         
22     }
23 
24 }

2, a collection (Collection) (master)

  (1) The origin of the collection?

    When we learn Java - Object Oriented - operation many objects - storage - container (array and StringBuffer) - arrays and arrays have a fixed length, it is not suitable to do was change the demand, Java provides a collection for our use .

  (2) collections and arrays have to distinguish?

    A: the length difference

      Fixed array

      Variable collection

    B: content difference

      Arrays can be basic types, it can also be a reference type

      Collection can only be a reference type

    C: element content

      Array can only store the same type

      Can store a collection of different types (actually a collection of general store was also the same type)

  (3) inherited a collection of architecture?

      Due to the different needs, Java provides a set of classes was different, but it was more like a collection of different data structures, but they are to provide storage containers and traverse functions too, we continue to extract them have in common upward,

Eventually formed the collection was inherited architecture.

  Collection

    |--List

      |--ArrayList

      |--Vector

      |--LinkList

    |--Set

      |--HashSet

      |--TreeSet

  (4) Collection was functional overview ( own padded)

    A: Adding functionality

    B: Delete function

    C: judgment function

    D: acquisition function

    E: length feature

    F: intersection (understand)

    G: The set switch array (Learn)

  (5) Collection traversal set to give

    A: The transfer set of arrays (Learn)

    (Code supplement)

    B: iterator (set specific embodiment)

              (Code supplement)

  (6) iterator

    A: Getting an element is set to give way to give

    B: is obtained depends on the collection exists

    C: iterator was the principle and source code

      a: Why To define an interface rather than an implementation class (if the class is achieved, then they would have to provide specific implementation method, but there are many in our collection, it is an interface)

      b: looked at the internal iterator class implementation

  (7) Case Collecton collection (traversal iterator)

    A set of steps:

      A: Create a collection object

      B: create element objects

      C: Add the element with a collection

      D: through the collection

    A: the storage and traversing string

    (Code supplement)

    B: store the custom objects and traverse

    (Code supplement)

2, a collection (List) (master)

  (1) List of sub interface Collection

    Features: Ordered (taken in the same order and the storage order) may be repeated.

  (2) List the specific features :( own padded)

    A: Adding functionality

    B: Delete function

    C: acquisition function

    D: iterator function

    E: editing

  (3) the unique collection of traversal function List

    A: binding by the size () and get ().

    B: code demonstrates

    (Supplementary Code) (an iterative device A for loop)

  (4) a list iterator's special features :( understand)

    You can reverse traversal, but the first forward traversal, so meaningless, basically do not use.

  (5) an abnormal concurrent modification

    A: An exception occurred

      Iterates over the collection, the collection modify the collection element

    B: The reason

      Iterator is dependent on a set of two points, and changing the set, the iterator does not know.

    C: Solution

      a: iterates over, iterator modified (the ListIterator)

        Elements are added in just the iterator position

        (Code supplement )

      b: traverse the set, set modification (size () and GET ())

 

        Element added to the end of the collection

        (Code supplement)

  (6) common data structure

    A: After the advanced stack

    B: FIFO queue

    C: an array of fast queries, additions and deletions slow

    D: list query anyway, slow, fast additions and deletions

  Characteristics subclass (7) List of (interview questions)

    ArrayList

      The underlying data structure is an array, query fast, slow additions and deletions.

      Thread-safe, high efficiency.

    Vector

      The underlying data structure is an array, query fast, slow additions and deletions.

      Thread-safe, low efficiency.

    LinkedList

      The underlying data structure is the list, slow queries, additions and deletions fast.

      Thread-safe, high efficiency.

    Who in the end to use it? Look demand?

    analysis:

      To secure?

        To: Vector (even if you want, this does not apply, for later)

        Do not: ArrayLIst or LinkedList

          Multi-query: ArrayList

          Deletions and more: LinkedList

      I do not know what the election when the election ArrayList.

 

 

 

 

Guess you like

Origin www.cnblogs.com/wyh-study/p/11846177.html