title: stackoverflowerror null
body: <p>The error i am having here is a infinite or near infinite loop in my method calls and class's creating other class's constructors.  What my program is trying to do is semi-randomly generate survey results based off actual statistics.  I would highly appreciate not only some insight in whats going wrong here.  But some advice and pointers on how to prevent this from happening and ways to analyze the error messages by myself.  I get how some of the work but like i stated below i am new to programming im a freshman in college so programming is new to me.  Thanks in advance and sorry for my previous post, thought i would take the time to give you guys an appropriate one.</p>
  
  <p>Im new to programming this is my 2nd project ive done on my own so im sorry if its not the best.</p>
  
  <p>This is my Test class:</p>
  
  <pre><code> public Tester()
  {
      randomGenerator = new Random();
      probability = new Probability();
      stats = new Statistics();
      double chance = randomGenerator.nextDouble();
      double gender = probability.getProbabilityOfMale();
      if(chance &gt; gender)
      {
          male = false;
          stats.incrementFemale();
      }else{
          male = true;
          stats.incrementMale();
      }
      age = randomGenerator.nextInt(49)+16;
      int range = stats.getNumberOfQuestion();
      for(int i=0;i&lt;range;i++)
      {
         probabilities = probability.probOfAnswer(i);
         answers = probability.getAnswers(i);
         chance = randomGenerator.nextDouble();
         int size = probabilities.size();
         for(int j=0;j&lt;size;j++)
         {
           double qTemp = chance - probabilities.get(j);
           if(qTemp &lt;= 0.0)
           {
               Answer aTemp = answers.get(j);
               aTemp.incrementCounter();
               answers.set(j,aTemp);
            }
         }
      }
  }
  </code></pre>
  
  <p>Statistics class:</p>
  
  <pre><code> public ArrayList&lt;Answer&gt; getAnswers(int index)
  {
      temp = survey.getAnswers(index);
      return temp;
  }
  
  public int getMale()
  {
      return male;
  }
  
  public int getFemale()
  {
      return female;
  }
  
  public int getNumberOfQuestion()
  {
      return numberOfQuestion;
  }
  
  public void incrementNumberOfQuestion()
  {
      numberOfQuestion++;
  }
  
  public void incrementMale()
  {
      male++;
  }
  
  public void incrementFemale()
  {
      female++;
  }
  </code></pre>
  
  <p>and probability class:</p>
  
  <pre><code> public Probability()
  {
      stats = new Statistics();
      probOfAnswer = new ArrayList&lt;Double&gt;(0);
  }
  
  public ArrayList&lt;Double&gt; probOfAnswer(int index)
  {               
      temp = stats.getAnswers(index);
      int size = temp.size();
      for(int i=0;i&lt;size;i++)
      {
          aTemp = temp.get(i);
          for(int j=0;j&lt;size;j++)
          {
              Answer aTemp = temp.get(j);
              sum += (double)aTemp.getCounter(); 
          }
          double number = (double)aTemp.getCounter();
          probOfAnswer.add(number/sum);
          sum = 0;
  
      }
      return probOfAnswer;
  }
  
  public ArrayList&lt;Answer&gt; getAnswers(int index)
  {
      temp = stats.getAnswers(index);
      return temp;
  }
  
  public ArrayList&lt;Double&gt; getProbofAnswer()
  {
      return probOfAnswer;
  }
  
  public void probabilityOfMale()
  {        
      double male = (double)stats.getMale();
      double female = (double)stats.getFemale();
      probabilityOfMale = male / (male + female);
  }
  
  public double getProbabilityOfMale()
  {
      return probabilityOfMale;
  }
  </code></pre>
  
  <p>These are the only real important parts where the loop exsists the rest of the code is not needed to be uploaded.  </p>
  
  <p>Im having difficulty uploading my error message on this site its not accepting it as code in the code insert, then it wont let me submit the message afterwards so im going to upload the code elseware and link it.</p>
  
  <p><a href="http://forum.overdosed.net/index.php/topic/56608-this-is-unimportant/" rel="nofollow">http://forum.overdosed.net/index.php/topic/56608-this-is-unimportant/</a></p>
  
  <p>But i dont know how long that forum will let me keep that post there >&lt;</p>