title: How to compare array in generic methods in java?
body: <p>I've got a class using two generic parameters in its constructor. I would like to implement a method to compare two instances of this class, as done in the code below.</p>
  
  <p>It works quite well except when one of the parameter is an arrays. I've read different topics about how to compare arrays with <code>java.util.Arrays.equals(Object[] a, Object[] a2)</code> but as my parameters are not defined as arrays, I can't use this method.</p>
  
  <p>How could return "true" in the content of my array is the same? Or is it possible to cast my parameters to use <code>java.util.Arrays.equals(Object[] a, Object[] a2)</code>?</p>
  
  <pre><code>public class Pair&lt;U, V&gt; {
  
      public final U first;
      public final V second;
  
      public Pair(U first, V second) {
          this.first = first;
          this.second = second;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o)
              return true;
          if (o == null || getClass() != o.getClass())
              return false;
  
          Pair&lt;?, ?&gt; myPair= (Pair&lt;?, ?&gt;) o;
  
          if (!first.equals(myPair.first) || !second.equals(myPair.second))
              return false;
          return true;
      }
  }
  </code></pre>