We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I don't know which type grid has to be, it's confusing.
Cell cell;
int cols, rows;
int size = 40;
Cell[] grid;
void setup(){
size(800, 600);
background(255);
cols = floor(width/size);
rows = floor(height/size);
for(int i = 0; i < rows; i++){
for(int j = 0; i < cols; j++){
cell = new Cell(i, j);
grid.append(cell);
}
}
}
void draw(){
background(255);
}
class Cell{
int i, j;
Cell(int _i, int _j){
i = _i;
j = _j;
}
}
Answers
Java arrays only got methods from the universal class Object, plus the field length and nothing more:
http://docs.Oracle.com/javase/8/docs/api/java/lang/Object.html
Processing's append() function is for occasionally grow the array. Shouldn't be abused due to performance & practical reasons.
Read more about it at these old forum links below:
Well, I did some changing and now I get a NullPointerException at line 14.i fixed it