Creating N nested for-loops

You may use recursion instead with a base condition –

void doRecursion(int baseCondition){

   if(baseCondition==0) return;

   //place your code here

   doRecursion(baseCondition-1);
}  

Now you don’t need to provide the baseCondition value at compile time. You can provide it while calling the doRecursion() method.

Leave a Comment