title: Linkedlist implementation in Java doesnot seem like linkedlist as in C++
body: <p>I was going through the LinkedList and seen the implementation in Java. Back in days when I tried and implemented the linkedlist, it was with pointers and addresses and a lot of hard work. With Java the implementation is easier but still took some doing on my part. What I know of linked list is clear from following diagram,where 1,2,3,4 are nodes of the linkedlist.
  <a href="https://i.stack.imgur.com/GgNYu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GgNYu.png" alt="enter image description here"></a></p>
  
  <p>However In java, the code I came across made me to think of the LinkedList as following diagram.<a href="https://i.stack.imgur.com/PKBfO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PKBfO.png" alt="enter image description here"></a></p>
  
  <p>The implementation code of linkedlist in Java is as follows,</p>
  
  <pre><code>class LinkedListNode
  {
      LinkedListNode nextNode = null;//consider this member variable
      int data;
      public LinkedListNode(int data)
      {
          this.data = data;
      }
      void appendItemToLinkedList(int newData)
      {
          LinkedListNode end = new LinkedListNode(newData);
          LinkedListNode temp = this;
          while (temp.nextNode != null) { temp = temp.nextNode; }
          temp.nextNode = end;
  
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public static void main(String[] args) 
      {
          LinkedListNode list = new LinkedListNode(10);
          list.appendItemToLinkedList(20);
          list.appendItemToLinkedList(30);
          list.appendItemToLinkedList(40);
          list.appendItemToLinkedList(50);
          list.appendItemToLinkedList(60);
      }
  </code></pre>
  
  <p>In the diagram , you can clearly see the node objects are inside the other node objects. Is it really a linked list.Or A parent container holding other container inside it and so on?</p>