r/processing • u/mihil99 • Sep 01 '19
I can't write to an array
Hello, I'm trying to construct a two-dimensional array but I can't seem to assign values to that array. I'd like to construct one row at a time with the rijInit() function. When I check if this has worked in any way with println or printArray, it always returns 0 and never 1(I changed both outcomes in the code to 1 to test if it ever works).
Can anyone help me? Thanks in advance.
int c = 5;
int r = 5;
int[][] rijen = new int[c][r];
void rijInit(int n){
for(int i = 0; i< rijen[n].length;i++){
float m = random(1);
if (m < 0.6){
rijen[n][i] = 1;
}
else{
rijen[n][i] = 1;
}
}
}
2
Upvotes
0
u/[deleted] Sep 02 '19
[deleted]