DiceRoll program using arrays, how can I accommodate multiple players?
<p>I am trying to make a program that takes an input for <code>#players</code> and <code>#dice</code> and rolls the dice whatever number of times for each player. It then outputs the rolls and the total. </p>

<p>So far I've managed to develop a program that can roll as many dice as inputted and store these values in an array, which it then sums and outputs. </p>

<p>Unfortunately, I'm stuck as of now because I don't really have any clue what to do when trying to make the program do this again each time for a new player. I understand it would probably be with an incrementer, but I'm just really overwhelmed by the complexity and don't even know what I would look for online.</p>

<p>Here is my code:</p>

<pre><code>package diceroll;

import java.util.ArrayList;
import java.util.Scanner;

public class DiceRoll {

public static void main(String[] args) {

int numplayers = 0, numdice = 0; // incrementers for #rolls and #players


  //  ArrayList&lt;ArrayList&gt; players = new ArrayList&lt;ArrayList&gt;();
 //   players.add(rolls);  /// adding list to a list
  //  System.out.println(players);

ArrayList&lt;Integer&gt; rolls = new ArrayList&lt;&gt;(); 

System.out.println("Enter the number of players.");
Scanner scan = new Scanner (System.in);
numplayers = scan.nextInt();

System.out.println("Enter the number of dice.");
numdice = scan.nextInt();

while (numdice &gt; 0 ) {

Die die1 = new Die();
die1.roll();
rolls.add(die1.getFaceValue());

numdice--;}

System.out.println(rolls);


  //  sum for array, but i cant access the arraylength 

int total = 0;
for (int n : rolls)    //what does the colon : do ?
{total += n;

System.out.println("Dice total:" + total);
 }
} 
} 
</code></pre>

<p>There is also a basic <code>Die.java</code> class that assigns a random number to face value and has the roll method I use to randomize the die.</p>

<p>Output:</p>

<p>run:
Enter the number of players.
1
Enter the number of dice.
4
[5, 4, 6, 6]
5
9
15</p>

<p>The only problem is changing the number of players currently has no effect. 
21</p>
