Im trying to achieve this in java... basically looping through 6 people then getting them to roll 100 random numbers, Just trying to loop through the array list names more efficiently rather than having 6 loops for the different people. Any help appreciated.
int min = 1;
int max = 6;
int range = (max - min + 1);
ArrayList person1 = new ArrayList();
ArrayList person2 = new ArrayList();
ArrayList person3 = new ArrayList();
ArrayList person4 = new ArrayList();
ArrayList person5 = new ArrayList();
ArrayList person6 = new ArrayList();
for (int i = 1; i <=6; i++) {
for (int j = 0; j <100; j++) {
int rand = (int) (Math.random() * range) + min;
// System.out.print(rand + ", ");
String person = "person" + i;
System.out.println(person);
person.add(rand);
}
}
System.out.println(person1);
System.out.println(person2);
System.out.println(person3);
System.out.println(person4);
System.out.println(person5);
System.out.println(person6);
ArrayLists, you used an array ofArrayLists.