NullPointerException?
in
Programming Questions
•
1 year ago
I was trying to run a program but kept getting the error, NullPointerException. I simplified my code down to as simple as can be to see if I could figure out what the problem was but it still eludes me. I usually like to figure things out on my own but this is driving me crazy. Can any of you see the issue? The error appears in line which reads: " rect(b.i, b.j, 100, 100); " inside the drawBox function.
void drawBox(thing b){
rect(b.i, b.j, 100, 100);
}
class thing{
int i;
int j;
thing(int ith, int jth){
i = ith;
j = jth;
}
}
thing cube;
void setup(){
size(600,600);
thing cube = new thing(250, 250);
}
void draw(){
drawBox(cube);
}
void drawBox(thing b){
rect(b.i, b.j, 100, 100);
}
class thing{
int i;
int j;
thing(int ith, int jth){
i = ith;
j = jth;
}
}
thing cube;
void setup(){
size(600,600);
thing cube = new thing(250, 250);
}
void draw(){
drawBox(cube);
}
1