title: How to implement String.endsWith() without using built-in method .endsWith() in Java
body: <p>I am trying to implement <code>String.endsWith()</code> method without the use of the built-in method <code>String.endsWith()</code>.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public static boolean endsWithSuffix(String str, String suffix) {
      char[] chStr = str.toCharArray();
      char[] chSuf = suffix.toCharArray();
  
      if(!str.contains(suffix) {
          return false;
      }
      return true;
  }
  </code></pre>
  
  <p>What is the best way to implement the <code>endsWith()</code> method without using the built-in method?</p>
  
  <p>I've been trying with character arrays but no luck yet. Would strings be easier?</p>