I create a file, and roll a dice which is saved on each row. Then I read the file, and save the dice rolls as an array.
I loop through the array and count how many 1,2,..,6 I get. These are called r1,r2,..r6 and are int's.
Now I want to create a new array with these ints (r1..r6).
I was thinking something like:
int [] sums = new int[6];
for (int i = 0; i < sums.length; i++) {
sums[i] = r(i+1); //get r1,r2,..,r6
}
This obviously doesn't work. I have tried to search how to do this. Can't figure it out.
Help?
note: I know since it is just six variables I can do
sums[0] = r1;
sums[1] = r2;
...
sums[5] = r6;
But I want to learn something new and do it with a loop (:
Thank you!
sumsarray and delete ther-variables.