I am getting stack overflow error in my code. In my program I want to generate a random integers of around 10-15 elements but there sum should be less than 100. Sometimes I am getting the output without any error but sometimes I am getting the error. Please provide if any better solution then this.
for (int i=1; i<= noOfQue; i++)
{
Random rand = new Random();
int randomNum = rand.nextInt((max - min) + 1) + min;
AppDelegate.LogE("Random Number Gen in Array - " + randomNum);
numberSequenceArray.add(randomNum);
result+=randomNum;
}
if(result > 100)
{
numberSequenceArray.clear();
AppDelegate.LogE("Result of Array - " + result);
genRandomArray();
}
else if( result < 100)
{
AppDelegate.hideLoadingDialog(getActivity());
AppDelegate.LogE("Result of Array - " + result);
final NumberFlash numflash = new NumberFlash(getActivity(),duration , tickingPeriod, min , max, "False", textNo, output, getFragmentManager(),"FingerMaths");
numflash.start();
}
Aucun commentaire:
Enregistrer un commentaire