title: Overriding equals in linked list
body: <p>Been searching for a solution to my problem. Been reading a lot about overriding equals to properly compare nodes of a linked list but have become stuck. Basically I am trying to search through my list and find a node that equals it and delete it. I have found the way to look through the linked list but when I return the node it is just gibberish. I am trying to find a way to get it into a string and compare it to another string. Anyway here is the code and my equals method that currently does not work.</p>
  
  <pre><code>public class MagazineList {
      private MagazineNode list;
      private Object obj;
  
      public MagazineList(){
          list = null;
      }
  
  
      public void add(Magazine mag){
          MagazineNode node = new MagazineNode(mag);
          MagazineNode current;
  
          if(list==null)
              list = node;
          else{
              current = list;
              while(current.next != null)
                  current = current.next;
              current.next = node;
          }   
      }
      public void insert(Magazine mag)
      {
          MagazineNode node = new MagazineNode (mag);
  
          // make the new first node point to the current root
          node.next=list;
  
          // update the root to the new first node
          list=node;
      }
      public void deleteAll(){
          if(list == null){
  
          }
          else{
              list = null;
          }
      }
  
      public void delete (Magazine mag) {
          MagazineNode current = this.list;
          MagazineNode before;
  
          //if is the first element
          if (current.equals(mag)) {
              this.list = current.next;
              return;     //ending the method
          }
  
  
          before = current;
  
          //while there are elements in the list
          while ((current = current.next) != null) {
  
              //if is the current element
              if (current.equals(mag)) {
                  before.next = current.next;
                  return;     //endind the method 
              }
  
              before = current;
          }
  
          //it isnt in the list
      }
      public boolean equals(Object other) {
  
          System.out.println("Here in equals" + other + this);
          // Not strictly necessary, but often a good optimization
          if (this == other)
              return true;
          else{
              return false;
          }
      }
  
      @ Override
      public String toString(){
          String result = " ";
  
          MagazineNode current = list;
          while (current != null){
              result += current.magazine + "\n";
              current = current.next;     
          }
          return result;
      }
  
  
      private class MagazineNode {
          public Magazine magazine;
          public MagazineNode next;
  
  
          public MagazineNode(Magazine mag){
              magazine = mag;
              next = null;
          }
      }
  }
  </code></pre>