title: Linked list .clear() method not working properly
body: <p>I have to make my own double linked list. I'm a beginner, so please forgive me my lack of knowledge. This list has to implement the List java interface, so I have a remove(int), a remove(Object), and a clear() method too, of which the clear() method does not do it's work, meaning it does not remove all elements of the list, only some. </p>
  
  <p>Here is the clear() method: </p>
  
  <pre><code>public void clear() {
      for (T t : this) {
          this.remove(t);
      }
      this.remove(this.size);
  }
  </code></pre>
  
  <p>The remove(Object)  method:</p>
  
  <pre><code>public boolean remove(Object o) {
      if (this.indexOf(o) &gt;= 0){
          remove(this.indexOf(o));
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>And finally, the remove(int) method:</p>
  
  <pre><code>public T remove(int index) {
      if (getNode(index) == null || this.isEmpty()) {
          return null;
      } else if (this.size == 1){
          this.size = 0;
          Node&lt;T&gt; currentNode = this.firstNode;
          this.firstNode = null;
          this.lastNode = null;
          return currentNode.data;
      }
  
      Node&lt;T&gt; currentNode = this.getNode(index);
  
      if (currentNode.nextNode != null){
          if (currentNode.previousNode != null){
              currentNode.previousNode.nextNode = currentNode.nextNode;
          } else {
              this.firstNode = currentNode.nextNode;
              this.firstNode.previousNode = null;
              this.size--;
              return currentNode.data;
          }
      }
      if (currentNode.previousNode != null){
          if (currentNode.nextNode != null) {
              currentNode.nextNode.previousNode = currentNode.previousNode;
          } else {
              this.lastNode = currentNode.previousNode;
              this.lastNode.nextNode = null;
              this.size--;
              return currentNode.data;
          }
      }
      currentNode = currentNode.nextNode;
      this.size--;
  
      for(int i = index; i &lt; this.size-1; i++){
          currentNode = currentNode.nextNode;
          currentNode.index--;
      }
  
      return currentNode.data;
  }
  </code></pre>
  
  <p>Please not only point out the place of the bug, but also help me improve this code, if you can. Thanks for your effort!</p>