Below is a piece of my program, i have printed out all the expressions. As the number of expressions it prints is incredibly large (over 5,000) and takes time i want to be able to count the number of expressions it will print instead of actually printing all the expressions.

Can anyone help?

Code:
newCalcWaiting=true; // to deal with a later possible equality
                         i = iva_level(level);
                         for (j = iva_level(level+1) ; j < iva_level(level+2) ; j++)
                             {if (i == highV[level])
                                {// ignore the first of the contributors to calculation
                                 i++;
                                }
                             if (i == lowV[level])
                                {// ignore the second of the contributors to calculation
                                 i++;
                                }
                             if (newCalcWaiting && (sorted[i]<=thiscalc 
                                                    || iva_level(level+1)<=i ) )
                                {// insert the new calculation into the next level
                                 sorted[j]=thiscalc;
                                 expression[j]=newform;
                                 newCalcWaiting=false;
                                 System.out.println("expression =  " + expression[j]);
                                 System.out.print(sorted[j]);
                                 System.out.println();
                                 
                                }