title: Is it possible to repeat external method calls by a user given times
body: <p>I guess this is a simple question but I can't find an answer on either Google or Stack Overflow. I am new to Java and I hope you can help me. I'm sorry in advance if I use the wrong terminology at any point when writing my question and code.</p>
  <p>My question is <strong>if there is any way to write a code that repeats an external method call?</strong></p>
  <p>The method I am calling is <code>shootWeapon</code> which exists in a class called <code>Weapon</code>. I'm calling that method from another method called <code>shootWithWeapon</code> which exists in a class called <code>Soldier</code>. My class <code>Soldier</code> has an inventory of weapons in <code>ArrayList&lt;Weapon&gt;</code> called <code>weaponList</code>. I would like to write a code that repeats <code>listWeapon.shootWeapon()</code> as many times as the user given <code>shootWithWeapon</code> parameter <code>usedAmmo</code>. My current code is working but it's only decreasing the ammo with 1 (since it's specified in the <code>shootWeapon</code> method).</p>
  <p><strong>This is my method in class &quot;Soldier&quot;.</strong></p>
  <pre><code>public void shootWithWeapon(String weaponChoice,int usedAmmo)
  
  int index = 0;
  while(index &lt; weaponList.size()){
  Weapon listWeapon = weaponList.get(index);
  String usedWeapon = listWeapon.getName(); //returns weapon name
  int xBullets = weaponList.getBulletAmount(); //returns amount of bullets in object
  
  if(weaponChoice.equals(usedWeapon) &amp;&amp; usedAmmo &lt; xBullets) {
  listWeapon.shootWeapon(); //This is the method I want to repeat * usedAmmo
  System.out.println(&quot;Your weapon have been used. You have &quot; + weaponList.getBulletAmount() + &quot; bullets left&quot;.); }
  
  index++;
  }
  }
  </code></pre>
  <p><strong>This is the method I'm calling in class &quot;Weapon&quot;.</strong></p>
  <pre><code>public void shootWeapon()
  {
  bulletAmount=bulletAmount - 1;
  }
  </code></pre>