title: Comparing 2 custom type arrays
body: <p>How do I compare 2 arrays with generic type. It's my main file with stack and it's function, I also pressed alt+insert and made new equals method</p>
  <pre><code>import java.util.Arrays;
  
  public class Stack&lt;T&gt; {
  
    int top;
    T[] stack;
  
    public Stack() {
      stack = (T[]) new Object[2];
      top = 0;
    }
  
    public void push(T element) {
      if ((top+1) == stack.length) {
        stack = Arrays.copyOf(stack, top + 2);
      }
      stack[++top] = element;
    }
  
    public void pop() {
      if (top == 0){
        System.out.print(&quot;Stack is already empty&quot;);
      }
      stack[top--] = null;
    }
    public int count() {
      return top;
    }
  
    @Override
    public int hashCode() {
      return super.hashCode();
    }
  
    @Override
    public boolean equals(Object obj) {
      return super.equals(obj);
    }
  }
  </code></pre>
  <p>And it's my file with tests</p>
  <pre><code>import org.junit.jupiter.api.Assertions;
  import org.junit.jupiter.api.Test;
  
  public class StackTests {
    @Test
    public void example() {
      Stack&lt;Integer&gt; actual = new Stack&lt;&gt;();
      actual.push(6);
      Stack&lt;Integer&gt; actual1 = new Stack&lt;&gt;();
      actual1.push(6);
      Assertions.assertEquals(actual,actual1);
    }
  }
  </code></pre>
  <p>I am trying to compare two equal arrays with  Assertions.assertEquals and new equals method, but it's wrong. In debug I see that my arrays have identical elements. Are there any ways to fix this? I'm new in Java, help me please</p>