title: Java using substring() to reverse String
body: <p>How is the String passed to this method getting reversed? If you pass "ABCD" the string become "DCBA", but I was thinking reverse(str.substring(1)) will call it self until it return "D" which will be concatenated with str.substring(0,1) which is D and the string returned to be "DD".JAVA programming Language.</p>
  
  <pre><code>private static String reverse(String str) {
      if (str.length() &lt;= 1) {
          return str;
      }
      return reverse(str.substring(1)) + str.substring(0, 1);
  }
  </code></pre>