title: how to uncompress a given string in java recursively?
body: <p>this is very easy using iteration but i have to do this using recursion. I tried to keep a count of how many times a char occurs in a string, the position and the rest of the string and output.</p>
  
  <pre><code>public static String uncompress(String compressedText) {
  
          return uncompress(compressedText, 1, 0, "");
  
      }
  
      public static String uncompress(String text, int count, int pos, String output) {
  
          if (text.equals("")) {
  
              return "";
          }
  
          if (Character.isLetter(text.charAt(pos))) {
  
              output += text.charAt(0);
              pos++;
          }
  
          else if(Character.isDigit(text.charAt(pos))) {
  
              count = text.charAt(pos) - '0';
              output += text.charAt(pos + 1);
              count++;
              pos++;
  
          }
  
          text = text.substring(pos + 1);
  
          uncompress(text, count, pos, output);
  
          return output;
      }
  </code></pre>