title: Java: How check if two arrays are in same order?
body: <p>For example, I have two arrays:</p>
  
  <pre><code>String [] arr1 ={"You", "book"};
  String [] arr2 ={"Do", "You", "like","book" };
  </code></pre>
  
  <p>I want to check if <code>arr1</code> match the <code>arr2</code> in terms of the same order. If <code>arr1</code> is <code>{"book", "You"}</code>, then <code>arr1</code> does not match <code>arr2</code>.</p>
  
  <p>Alright, I think that my code is wrong, but anyway:</p>
  
  <pre><code>for (int i = 0; i&lt;arr1.length; i++){
    for (int j=0; j&lt;arr2.length; j++){
      if (arr1[i] != arr2[j]){
        return null;
      }
    }
  }
  </code></pre>
  
  <p>But when I run it, it always return <code>null</code> even my <code>arr1</code> does match <code>arr2</code>.</p>