title: Comparing arrays in a function with null values
body: <p>I'm currently learning about function and have the given task:</p>
  
  <p><em>"Write a function eqarr, which takes two int-arrays as arguments and returns true, if they are equal, and false otherwise; your function should return a value in every case (even if the arrays are null)"</em></p>
  
  <p>I'm having issues with checking if an array is null. I'm getting the arrays to check if the equal against one another, but with null it's a different issue. Whenever i try and check if a[i] is equal to null <code>a[i] == null</code>, i get this error <code>error: bad operand types for binary operator '=='</code>.</p>
  
  <p>We can't use existing functions.</p>
  
  <p>Any help would be appreciated. </p>
  
  <p>Cheers</p>
  
  <pre><code>public class Week8Q5 {
  
    public static boolean eqarr(int[] a, int[] b) {
  
      for (int i = 0; i &lt; a.length; i++) {
  
        if (a[i] != b[i])
          return false;
  
      }
      return true;
    }
  
    public static void main(String[] args) {
  
      int[] a = { 5, 6, 7, 8 };
      int[] b = { 5, 6, 7, 8 };
  
      System.out.println(eqarr(a, b));
  
    }
  }
  </code></pre>