title: Java - Basic use of arrays
body: <p>This is a basic question but I do need some help.</p>
  
  <p>Given two arrays of ints, a and b, return true if they have the same first element or they have the same last element. Both arrays will be length 1 or more.</p>
  
  <blockquote>
    <p>commonEnd({1, 2, 3}, {7, 3}) → true</p>
    
    <p>commonEnd({1, 2, 3}, {7, 3, 2}) → false</p>
    
    <p>commonEnd({1, 2, 3}, {1, 3}) → true</p>
  </blockquote>
  
  <p>I have the following code but it wont compile:</p>
  
  <pre><code>public boolean commonEnd(int[] a, int[] b) {
      if(a[0] == b[0] || a[a.length-1] ==b[b.length-1])
          return true;
  }
  </code></pre>