java - What does node class do in LinkedList class -


i trying understand how java creating nodes i.e. making linked list.so checking linkedlist.java file , saw inner node class in linked list class inner node class responsible creating nodes?

also when use class object created linkedlist class or node class?

 public class linkedlist<e>   extends abstractsequentiallist<e>   implements list<e>, deque<e>, cloneable, java.io.serializable   {  private static class 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;     } } 

p.s not duplicate trying understand node class doing in built in linkedlist class double linked list .in other question creating new singly linked list

the innner node class not responsible creating nodes. is node, or represents node in linked list. since items can , linkedlist wants link items (know before , next each item) needs node abstraction keep item , information.

enter image description here

so linkedlist creates nodes , connects them. keeps pointer first , last of nodes manage connections , avoid going in circles when iterating.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -