1
Can anyone tell me how to create a vector in java? i.e.: How to make a vector store other vectors with int values
this loop populates a vector with values from 1 to 4 q are directions N=North, S=South, L=East, O=West.
for (int i =0; i < aux; i ++) {
v[i] = (int) (Math.random() *4);
if(v[i] == 0){
N++;
System.out.println("N");}
if(v[i] == 1){
S++;
System.out.println("S");}
if(v[i] == 2){
L++;
System.out.println("L");}
if(v[i] == 3){
O++;
System.out.println("O");}
}
my goal is to store the results in other 4 vectors
Welcome to the OS, Joyce! The concept you are looking for would be that of matrices, perhaps? v[i][j]
– Cleber Griff
Array of array of how many sizes? 2? is just add a couple more
[]
in front q Voce adds one more dimension.– user28595
the array is of varying size because I use an Rand to assign any value( between 0 and 10) to the aux variable. Then in the end there are 4 arrays with varying sizes and random numbers inside. Maybe matrix is the solution wanted q to look like this array1 = N O L S O L L N O L array2 = N N N N L O S L O L .... etc where q each letter represents a number q will be counted
– Joyce Larissa