But my idea, in code, for it is to make different variables to store each number. But that would take forever.
You need 100 variables, one each to hold the tally count for that data value. Now if there was only an easy way to declare variables in bulk... Hmmm.... anything ring a bell... declare 100 at a time...
You need 100 variables, one each to hold the tally count for that data value. Now if there was only an easy way to declare variables in bulk... Hmmm.... anything ring a bell... declare 100 at a time...
i was thinking about using an array.... would that help
My knee-jerk reaction is to use the collection framework over an array in all but trivial cases, because the collection framework is more flexible.
But even so, sometimes the array code is simpler:
[CODE=Java]import java.util.*;
public class Comparison {
private static final int MAX = 10;
public static void main(String[] args) {
int[] v = new int[MAX]; //MAX zeroes
List<Integer> list = new ArrayList<Integ er>(Collections . nCopies(MAX, 0)); //MAX zeroes
//increment the values at odd offsets
for(int i=1; i<v.length; i+=2) {
v[i]++;
}
//increment the values at odd offsets
for(int i=1; i<list.size(); i+=2) {
list.set(i, 1 + list.get(i));
}
Comment