1. Linked list
One of the major drawbacks of arrays and ArrayList is that deleting an element from an intermediate location costs a great price, because after the element is deleted, all elements are moved to the front end, and this is the reason for inserting an element somewhere in the middle.
(Small sentiment: Sun-zheng said a sentence, every day in that quietly write code, is the most relaxed life, do not run that run, no need to spend too much breath, every day air conditioning, outside is the building, others wind blowing day race, really write code is one of the most relaxed things)
In this course of data structure, when we add or delete an element in a linked list, the pointer around it may have left a very bad impression, so the Java Collection Class Library provides a class LinkedList for developers to bring great convenience
******************
The increase of the linked list
*******
Increase
It's the same. Output results
**************************
Change
********
By deleting
Directly calling the iterator interface contains 3 methods, Next () Hasnext () remove () will be able to complete most functions of the field
****************
An iterator is a design pattern that is an object that can traverse and select objects in a sequence, and the developer does not need to know the underlying structure of the sequence . Iterators are often referred to as "lightweight" objects because they are less expensive to create.
The iterator functionality in Java is relatively simple and can only be moved one way:
(1) Use Method iterator () "Call this method by the Collection object Object" requires the container to return a iterator. The first time you call Iterator's next () method, it returns the first element of a sequence. Note: The iterator () method is an Java.lang.Iterable interface that is inherited by collection.
(2) Use Next () to get the next element in the sequence. The following 3 methods are called by ITER in iterator ITER.
(3) Use Hasnext () to check if there are elements in the sequence.
(4) use remove () to delete the newly returned element of the iterator.
**************************
Iterator is the simplest implementation of Java iterators, with more functionality for the Listiterator interface designed for list, which can traverse the list in two directions or insert and delete elements from a list.
***************************
Find
List of Java data Structures (Java Core Volume Ⅰ reading notes)