title: How to find the subsequence of number in java in simplest way
body: <p>I am using below program for printing all possible sub sequence </p>
  
  <pre><code>class Test {
  
      static void printSubSeqRec(String str, int n, int index, String curr) {
          if (index == n) {
              return;
          }
          System.out.println(curr);
  
          for (int i = index + 1; i &lt; n; i++) {
              curr += str.charAt(i);
              printSubSeqRec(str, n, i, curr);
  
              curr = curr.substring(0, curr.length() - 1);
          }
      }
  
      static void printSubSeq(String str) {
          int index = -1;
          String curr = "";
  
          printSubSeqRec(str, str.length(), index, curr);
      }
  
      public static void main(String[] args) {
          String str = "24";
          printSubSeq(str);
      }
  
  }
  </code></pre>
  
  <p>Output:</p>
  
  <p>2
  4
  24</p>
  
  <p>Is there any other way for getting the same result?</p>