title: How to Check If Two String Arrays are The Same
body: <p>I'm trying to solve a problem on "practice it", and I'm not able to pass all the tests to it.</p>
  
  <p>The problem is: </p>
  
  <blockquote>
    <p>Write a method called equals that takes in two string arrays and
    returns true if they are equal; that is, if both arrays have the same
    length and contain equivalent string values at each index.</p>
  </blockquote>
  
  <p>I have tried the following code, but the test to the input 
  <code>equals({"a", "b", "a", "c", "a", "d", "a", "e", "a"}, {"x", "b", "a", "c", "a", "d", "a", "e", "a"})</code> but it doesn't work.</p>
  
  <pre><code>public static boolean equals (String [] txt1, String [] txt2){
      boolean result=false;
      if(txt1.length==txt2.length){
          for(int i=0; i&lt;txt1.length; i++){
              if(txt1[i].equals(txt2[i])){
                  result = true;
              }
              else {
                  result = false;
              }
          }
      }
      else {
          return false;
      }
      return result;
  }
  </code></pre>
  
  <p>Expected return: <code>false</code>
  My return: <code>true</code></p>