title: Dynamically change the number of nested for loops
body: <p>I don't know if this is a stupid question, but I need to dynamically change the number of for-loops without using recursion.</p>
  
  <p>For example, if n=3, I need 3 nested for-loops.</p>
  
  <pre><code>for(int i=0; i&lt;size; i++){
     for(int j=0; j&lt;size-1; j++){
         for(int k=0; k&lt;size-2; k++){
            //do something
         }
     }
  }
  </code></pre>
  
  <p>If n=5:</p>
  
  <pre><code>for(int i=0; i&lt;size; i++){
     for(int j=0; j&lt;size-1; j++){
         for(int k=0; k&lt;size-2; k++){
            for(int l=0; l&lt;size-3; l++){
                for(int m=0; m&lt;size-4; m++){
                    //do something
                }
            }
         }
     }
  }
  </code></pre>
  
  <p>Is there any way to achieve this without recursion?
  Another question: what is the use of Multiple Dispatch in Java? I'm trying to code something in ONE METHOD, and it should run different events in different cases of the parameter. NO IF STATEMENTS / TERNARY OPERATORS / CASES.</p>
  
  <p>NOTE: I can ONLY have one method (part of the problem), and cannot use recursion. Sorry.</p>