once again.. a NullPointerException error
in
Programming Questions
•
3 years ago
Hi,
this is a strange behavior for me. If I increment the array with the keyboard (like in the code) everything works fine,
but if I change the variable (Count) over OSC I get a NullPointerException. (I have checked the incoming OSC message)
Thanks in advance!
This comes up:
processing.app.debug.RunnerException: NullPointerException
at processing.app.Sketch.placeException(Sketch.java:1543)
at processing.app.debug.Runner.findException(Runner.java:583)
at processing.app.debug.Runner.reportException(Runner.java:558)
at processing.app.debug.Runner.exception(Runner.java:498)
at processing.app.debug.EventThread.exceptionEvent(EventThread.java:367)
at processing.app.debug.EventThread.handleEvent(EventThread.java:255)
at processing.app.debug.EventThread.run(EventThread.java:89)
Exception in thread "Animation Thread" java.lang.NullPointerException
at processing.core.PVector.add(PVector.java:201)
at cubixForm_final5.drawVectors(cubixForm_final5.java:172)
at cubixForm_final5.update(cubixForm_final5.java:99)
at cubixForm_final5.draw(cubixForm_final5.java:93)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:637)
This is part of my code:
this is the part where the array gets out of bounds:
this is a strange behavior for me. If I increment the array with the keyboard (like in the code) everything works fine,
but if I change the variable (Count) over OSC I get a NullPointerException. (I have checked the incoming OSC message)
Thanks in advance!
This comes up:
processing.app.debug.RunnerException: NullPointerException
at processing.app.Sketch.placeException(Sketch.java:1543)
at processing.app.debug.Runner.findException(Runner.java:583)
at processing.app.debug.Runner.reportException(Runner.java:558)
at processing.app.debug.Runner.exception(Runner.java:498)
at processing.app.debug.EventThread.exceptionEvent(EventThread.java:367)
at processing.app.debug.EventThread.handleEvent(EventThread.java:255)
at processing.app.debug.EventThread.run(EventThread.java:89)
Exception in thread "Animation Thread" java.lang.NullPointerException
at processing.core.PVector.add(PVector.java:201)
at cubixForm_final5.drawVectors(cubixForm_final5.java:172)
at cubixForm_final5.update(cubixForm_final5.java:99)
at cubixForm_final5.draw(cubixForm_final5.java:93)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:637)
This is part of my code:
- int Count =50;
PVector[] n = new PVector[0];
void setup()
{
size(400,400);
}
void draw()
{
n = new PVector[Count];
for (int i=0; i<=Count; i++)
{
//drawing
}
}
void keyPressed()
{
if(key == '+') {Count=Count+100; println(Count);}
}
this is the part where the array gets out of bounds:
- for (int i = 0; i < Count; i++) {
PVector x = VecArray[i]; <====== here
1