title: Dynamic amount of loops through permutations
body: <p>I've got a program that will dynamically access different methods and each method will have different amounts of parameters. I need to find a way to permute through thousands of different arrangements of these parameters, and I'm not sure how to loop through these permutations dynamically.</p>
  
  <p>For instance, for a function that has two parameters, I can iterate through the permutations like this:</p>
  
  <pre><code>public static void main(String[] args) {
      List&lt;Object[]&gt; params = new ArrayList();
      params.add(new Integer[]{1,2,3});
      params.add(new Boolean[]{false,true});
  
      runCalculation("function1",params);
  }
  
  public void runCalculation(String functionName, List&lt;Object&gt; parameters){
  
      for(Object i : parameters.get(0)){
          for(Object j : parameters.get(1)){
              //Do reflection function call with (i,j) as parameters
          }
      }
  }
  </code></pre>
  
  <p>But if I were to have the next function I want to run use 3 parameters, this will no longer iterate through all the permutations. How can I use a dynamic amount of for loops to correctly process a list of arrays containing parameter values? I think recursion is the only way to implement something like this but I'm still struggling to think up a correct solution to this that will correctly allow for a dynamic amount of parameters for each function, and then different types for these parameters.</p>