NullPointException Problem
in
Programming Questions
•
1 years ago
Hi,
Just a quick very novicy question for you all. I've come across a NullPointException error when trying to use a function within a class...
The code is as follows...
import processing.opengl.*;
vertexPoint pointA;
void setup(){
// framerate(10);
background(75,75,75);
size(screen.width,screen.height,OPENGL);
stroke(255,255,255,235);
strokeWeight(5);
smooth();
strokeCap(ROUND);
fill(255,255,255,128);
//Draw line
pointA.update();
line(pointA.coordinates[0][0][0],pointA.coordinates[0][1][0],pointA.coordinates[1][0][0],pointA.coordinates[1][1][0]);
}
void draw(){
}
class vertexPoint{
//Create test array 3D
int [] [] [] coordinates ={
{
{0,0},
{0,0},
{0,0}
},
{
{0,0},
{0,0},
{0,0}
},
{
{0,0},
{0,0},
{0,0}
},
};
void update(){
for(int i=0; i<=2; i++){
for(int j=0; j<=2; j++){
coordinates[i][j][1]=coordinates[i][j][1];
coordinates[i][j][0]=int(random(screen.height));
}
}
}
}
Any ideas why it comes up with the error when I call pointA.update(); ?
Also, another quick one to add onto the end... Is there any way to create a multi-dimensional array without having to populate is straight away?
Kind regards,
Andrew
1