title: Transposing a matrix represented as a string?
body: <p>I have a 25 character long string where every subsequent 5 characters represent a row in the matrix.</p>
  
  <pre><code>String matrix="qwsedrhendtedksiehwnehsbt";
  </code></pre>
  
  <p>I am trying to transpose it using a function</p>
  
  <pre><code>public String transpose(String str) {
  
      if (str == null || str.length() == 1 || str.length() == 2) {
          return str;
      } else {
          return str.substring(0, 1) + str.substring(str.length() -1, str.length()) + transpose(str.substring(1, str.length() -1) );
      }
  }
  </code></pre>
  
  <p>produces </p>
  
  <pre><code>result="qtwbssehdernhwehneditsekd"
  </code></pre>
  
  <p>this isnt the expected result.
  the result must be</p>
  
  <pre><code>expectedResult="qrtiewheehsedhsenkwbddsnt"
  </code></pre>
  
  <p>I am not able to understand where I am going wrong</p>