title: Efficient method to find permutations of variable number of arrays containing varibale number of elements
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2189303/how-can-i-find-all-of-the-permutations-consisting-of-1-element-from-a-variable-n">How can I find all of the permutations consisting of 1 element from a variable number of arrays of variable length?</a>  </p>
  </blockquote>
  
  
  
  <p>Suppose I have n arrays with elements like below</p>
  
  <pre><code> a1 -&gt; e11,e12,e13
  
   a2 -&gt; e21,e22,e23,e24,e25
  
   a3 -&gt; e31,e32
  
   a4 -&gt; e41,e42,e43,e44
  
   ...
  
   an -&gt; en1,en2,en3,en4,en5,en6
  </code></pre>
  
  <p>I want to get all possible permutations with n elements in it from each array above.</p>
  
  <p>For exm. </p>
  
  <pre><code> e11,e21,e31,e41.........,en1
  
   e13,e25,e32,e41.........,en6
  </code></pre>
  
  <p>and so on...</p>
  
  <p>Suggest me an efficient method and if possible code snippet in Java or C.</p>