title: How can I make a method repeat itself? Java
body: <p>I have a method that fills an array and I need to find a way to make it repeat a number of times. The purpose is to iterate and reiterate the density of a planet to narrow its mass,gravity and densities at specific points which are concentric shells. This is my first program but, I have learned a decent amount while working on this I think. Thanks everyone</p>
  
  <p>Here is my code sample of the density calculation. I probably included too much but oh well. So I need to make this iterate selected number of times. Each iteration needs to be put back into the mass calculation which will then be put back into the gravity calculation. And then the show starts again. </p>
  
  <pre><code>public class ItrDensityGrid {
  
      public double itrrho[];
      double b = InitialConditions.bmod;  
  
      // Iterating grid of densities 
  
      public ItrDensityGrid(int shells, double radius, double mass){
  
              GravityGrid gg = new GravityGrid(shells, radius, mass); 
  
              for(int k = shells; k &gt;= 0; k--){
  
                      itrrho[k] = (itrrho[k]*(1+(gg.alpha[k]*(1.0 / 2)))*(1 / (1-((gg.alpha[k])*(1.0 / 2)))));
  
          }
      }
  }
  </code></pre>