title: Equals method implementation for arrays - Java
body: <p>I'm surprised this <code>equals</code> method works.. even though it's using <code>.equals</code> which does not exist in its old form anymore since I've overwritten it..?</p>
  
  <p>What I mean is, if you look at the code, to compare the two array elements I'm using <code>.equals</code>.</p>
  
  <p>But.. if I'm overwriting the equals method, wouldn't <code>.equals</code> just use my overwritten method?
  I'm a little confused, I would really appreciate some explanation as to how that works.</p>
  
  <pre><code>public boolean equals(Object other) {
      if (other instanceof arrayClass) {
          arrayClass that = (arrayClass) other;
          if (this.number == that.number) {
              for (int i = 0; i &lt; this.number; i++) {
                  if (this.elements[i].equals(that.elements[i])) {
  
                  }
                  else {
                      return false;
                  }
              }
              return true;
          }
          else {
              return false;
          }
      }
      else {
          return false;
      }
  }
  </code></pre>
  
  <p>Note: <code>number</code> represents the arrays length.</p>
  
  <p>Thanks in advance!</p>