A linked list is a non-sequential, non-sequential storage structure on a physical storage unit, and the logical order of the data elements is achieved through the order of the pointers in the linked list. A linked list consists of a series of nodes (each element in the list is called a node) that can be dynamically generated at run time.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/4A/wKioL1Y1XS-zgcqwAAJwvo9n5Q4838.jpg "title=" QQ picture 20151101081241.png "alt=" Wkiol1y1xs-zgcqwaajwvo9n5q4838.jpg "/>
One-way Node instance:
Public class nodetest { public static void main (String[] args) { node node1 = new node ("Node1") ; node node2 = new node ("Node2"); node node3 = new node ("Node3"); //build a linked list node1.next = node2; node2.next = node3; system.out.println (Node1.next.next.data); //Inserts a node node node4 = new node ( "Node4"); node4.next = node1.next; Node1.next = node4; system.out.println ( Node1.next.next.next.data); }}class node{ string data; node next; public node (String data) { this.data = data; }}
Two-way node nodes are similar to one-way node nodes, but have a pointer to the previous node in the node declaration.
Public class nodetest { public static void main (String[] args) { node node1 = new node ("Node1") ; node node2 = new node ("Node2"); node node3 = new node ("Node3"); //build a linked list node1.next = node2; node2.previous = node1; node2.next = node3; node3.previous = node2; node3.next = node1; &nbSp; node1.previous = node3; system.out.println ( Node1.next.previous.data); //Inserting a node (inserting a node requires modifying four pointers) node node4 = new node ("Node4"); node4.next = node1.next; node1.next.previous = node4; node4.previous = node1; node1.next = node4; system.out.println ( Node1.next.next.data); }}class node{ node previous; string data; node next; public node (string data) { this.data = data; }}
Java record -48-JAVA data structure-linked list