title: Java, Simplified check if int array contains int
body: <p>Basically my mate has been saying that I could make my code shorter by using a different way of checking if an int array contains an int, although he won't tell me what it is :P.</p>
  
  <p>Current: </p>
  
  <pre><code>public boolean contains(final int[] array, final int key) {
      for (final int i : array) {
          if (i == key) {
              return true;
          }
      }
      return false;
  }
  </code></pre>
  
  <p>Have also tried this, although it always returns false for some reason.</p>
  
  <pre><code>public boolean contains(final int[] array, final int key) {
      return Arrays.asList(array).contains(key);
  }
  </code></pre>
  
  <p>Could anyone help me out?</p>
  
  <p>Thank you.</p>