title: Which is faster in Java, while or using recursive method?
body: <p>I have the following sample <code>class</code> with these two methods:</p>
  
  <p><strong>Process.java:</strong></p>
  
  <pre><code>public class Process {
  
      public Process() {
      }
  
      public static void countRecursive(int num) {
          System.out.println("countRecursive: " + num++);
          if (num &lt;= 10) countRecursive(num);
          else return;
      }
  
      public static void countWhile(int num) {
          do System.out.println("countWhile: " + num++);
          while (num &lt;= 10);
      }
  
  }
  </code></pre>
  
  <p><strong><em>Main class:</em></strong></p>
  
  <pre><code>public static void main(String[] args) {        
  
      Process.countRecursive(0);
      Process.countWhile(0);
  
  }
  </code></pre>
  
  <p><strong><em>Output:</em></strong></p>
  
  <pre><code>countRecursive: 0
  countRecursive: 1
  countRecursive: 2
  countRecursive: 3
  countRecursive: 4
  countRecursive: 5
  countRecursive: 6
  countRecursive: 7
  countRecursive: 8
  countRecursive: 9
  countRecursive: 10
  
  countWhile: 0
  countWhile: 1
  countWhile: 2
  countWhile: 3
  countWhile: 4
  countWhile: 5
  countWhile: 6
  countWhile: 7
  countWhile: 8
  countWhile: 9
  countWhile: 10
  </code></pre>
  
  <p>But I want to know which "technique" is recommended to use and why.</p>
  
  <p>Thanks in advance.</p>