title: Add and Print new Nodes
body: <p>I was working on a program to add nodes to a list, but I seem to be doing something wrong...</p>
  <p>My java program has three Classes; Demo, Lista and Node</p>
  <p>Class Node:</p>
  <pre><code>public class Node {
      
      private int num;
      private Node tail;
      private Node head; 
  
      public Node (int num, Node head, Node tail) {
          this.num = num;
          this.head = head;
          this.tail = tail;
      }
  }
  </code></pre>
  <p>Class Lista:</p>
  <pre><code>public class Lista {
      
      private Node nil;
      
      public Lista () {
          nil = null;
      }
      
      public void add (int num) {
          Node newNode = new Node(num, head, tail);
          
          if (head == null) {
              head = newNode;
              tail = newNode;
          }
      }
      
      public void display () {
          Node current = head;
          
          while(current != null) {
              System.out.print(current.num);
          }
      }
  }
  </code></pre>
  <p>Class Demo:</p>
  <pre><code>public class Demo {
      
      public static void main ( String [] args) {
          Lista lista = new Lista();
          lista.add(3);
          lista.add(9);
          lista.add(7);
          lista.display();
      }
  }
  </code></pre>
  <p>Demo class is to add the different nodes to the list &quot;lista&quot;. Class Node has num, head which is the next one and tail which is the previous one. How can I go about getting Class Lista to be able to use head and tail from Class Node? And if it is possible would this code work when running Demo? What should I change/modify to get this to work?</p>