title: Why is my code for Codingbat String-2 EndOther not working?
body: <p>I won't lie, this is sort of homework for my AP Computer Science class. But I talked to my teacher, and he couldn't figure it out either.</p>
  
  <p>So I'm doing the Java CodingBat problem String-2 endOther <a href="http://codingbat.com/prob/p126880" rel="nofollow noreferrer">here</a>, and I don't know why my code isn't working properly.</p>
  
  <p>The goal of the challenge is to determine if one string appears at the very end of the other string. If so, return true, otherwise return false.</p>
  
  <p>Example: If the strings were "Hiabc" and "abc", it would return true, but "Hiabcx" and "bc" would return false because "bc" isn't at the end.
  Note: Case does not matter.</p>
  
  <p>My code works for all of the examples that it runs through, except for "other tests". I might have been able to figure out how to fix it, except I don't know what "other tests" it ran. So any help on this? Here's my code:</p>
  
  <pre><code>public boolean endOther(String a, String b) {
      a = a.toLowerCase();
      b = b.toLowerCase();
      if (a.contains(b) &amp;&amp; a.indexOf(b) == a.length() - b.length()) {
          return true;
      } else if (b.contains(a) &amp;&amp; b.indexOf(a) == b.length() - a.length()) {
          return true;
      } else {
          return false; 
      }
  }
  </code></pre>
  
  <p>Thanks!</p>