title: Using a class that is not implemented in the java interface
body: <p>I am making a double ended queue(deque) and now i am trying call my list and adding data to it. But i have a struggle with the fact that i cannot get non-static variables from static context. </p>
  
  <p>In this case i am trying to access my variables from the Node class that i made.</p>
  
  <p>My question is: How can i access my variables in the Node class without changing my java interface? </p>
  
  <p>Here is my code:</p>
  
  <pre><code>import java.util.Iterator;
  import org.w3c.dom.Node;
  
  public abstract class Deque implements DoubleEndedQueue&lt;Object&gt; {
  
  private Node&lt;Object&gt; first;
  private Node&lt;Object&gt; last;
  private Node&lt;Object&gt; newNode;
  private int size = 0;
  
  public Deque() {
      size = 0;
      first = null;
      last = null;
  }
  
  private class Node&lt;Object&gt; {
  
      Object item;
      Node&lt;Object&gt; prec;
      Node&lt;Object&gt; next;
  }
  
  public Iterator&lt;Object&gt; iterator() {
      return new Iterator&lt;Object&gt;() {
  
          private Node&lt;Object&gt; node = first;
  
          @Override
          public boolean hasNext() {
              return node != null;
          }
  
          @Override
          public Object next() {
              Object item = node.item;
              node = node.next;
  
              return item;
          }
  
          @Override
          public void remove() {
              throw new UnsupportedOperationException();
          }
      };
  }
  
  public static void main(String[] args) {
      DoubleEndedQueue&lt;Object&gt; doubleEndedQueue = new DoubleEndedQueue&lt;Object&gt;() {
  
          @Override
          public boolean isEmpty() {
              return size == 0;
          }
  
          @Override
          public int size() {
              return size;
          }
  
          @Override
          public void pushLeft(Object item) {
              newNode.item = item;
              if (size == 0) {
                  first = last = newNode;
              } else {
                  newNode.next = first;
                  first.prec = newNode;
              }
              first = newNode;
              if (last == null) {
                  last = first;
              }
              size++;
          }
  
          @Override
          public void pushRight(Object item) {
              newNode.item = item;
  
              if (size == 0) {
                  last = first = newNode;
              } else {
                  newNode.prec = last;
                  last.next = newNode;
              }
              last = newNode;
              if (first == null) {
                  first = last;
              }
              ++size;
          }
  
          @Override
          public Object popLeft() {
              newNode = first;
              first = first.next;
  
              if (first == null) {
                  last = null;
              } else {
                  first.prec = null;
              }
  
              size--;
  
              return newNode.item;
          }
  
          @Override
          public Object popRight() {
              newNode = last;
              last = newNode.prec;
  
              if (last == null) {
                  first = null;
              } else {
                  last.next = null;
              }
  
              size--;
  
              return newNode.item;
          }
  
          @Override
          public Object changeLeft(int n, Object newItem) {
              newNode = first;
              for (int i = 0; i &lt; n; i++) {
                  newNode = newNode.next;
              }
              return newNode.item = newItem;
          }
  
          @Override
          public Object changeRight(int n, Object newItem) {
              newNode = last;
              for (int i = 0; i &lt; n; i++) {
                  newNode = newNode.prec;
              }
              return newNode.item = newItem;
          }
  
      };
      d.pushLeft("im first");
      d.pushLeft("im second");
      d.pushRight("im third");
      d.pushRight("im fourth");
      d.pushLeft("im fifth");
      d.pushRight("im sixth");
      d.changeLeft(1, "well");
      d.changeRight(2, "this");
      d.changeLeft(1, "was");
      d.changeRight(3, "fun");
      d.popRight();
      d.popLeft();
      for (String i : d) {
          System.out.print(i + " ");
      }
  
  }
  }
  </code></pre>