title: How do I determine if an array contains all the integers in a separate array
body: <p>I'm in my schools ap computer science class and I'm stuck on this one problem. and cant really even really come up with an idea on how to solve it.</p>
  
  <p>Here it is word for word:
  Write a static method named <code>contains</code> that accepts two arrays of integers a1 and a2 as parameters and that returns a boolean value indicating whether or not a2's sequence of elements appears in a1 (true for yes, false for no). The sequence of elements in a2 may appear anywhere in a1 but must appear consecutively and in the same order. For example, if variables called list1 and list2 store the following values:</p>
  
  <pre><code>int[] list1 = {1, 6, 2, 1, 4, 1, 2, 1, 8};
  int[] list2 = {1, 2, 1};
  </code></pre>
  
  <p>Then the call of <code>contains(list1, list2)</code> should return true because list2's sequence of values <code>{1, 2, 1}</code> is contained in list1 starting at index 5. If list2 had stored the values <code>{2, 1, 2}</code>, the call of <code>contains(list1, list2)</code> would return false because list1 does not contain that sequence of values. Any two lists with identical elements are considered to contain each other, so a call such as <code>contains(list1, list1)</code> should return true.</p>
  
  <p>You may assume that both arrays passed to your method will have lengths of at least 1. You may not use any Strings to help you solve this problem, nor methods that produce Strings such as Arrays.toString.</p>
  
  <p>If someone could point me in the right direction that would be great.</p>
  
  <p>also here's one attempt i came up with but it doesn't have a sufficient number of tests</p>
  
  <pre><code>public static boolean contains(int[] set1, int[] set2) {
      boolean contains = false;
      for (int i = 0; i &lt; set1.length; i++) {
          for (int a = 0; a &lt; set2.length - 1; a++) {
              if (set1[i] == set2[a] &amp;&amp; set1[i + 1] == set2[a + 1]) {
                  contains = true;
              } else {
                  contains = false;
              }
          }
      }
      return contains;
  }
  </code></pre>