We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Little Boring Erro
Page Index Toggle Pages: 1
Little Boring Erro (Read 306 times)
Little Boring Erro
Mar 12th, 2009, 1:21am
 
I'm gettim this crazy error on this simple code...

i realy don't know what's happening

code:

class objs{
 int marcelo;
 float mariana;
}

objs[] sa1 = new objs[256];

sa1=(objs[])splice(sa1,sa1[5],3);


error:


Exception in thread "Animation Thread" java.lang.NullPointerException
at processing.core.PApplet.splice(PApplet.java:4885)
at teste.setup(teste.java:23)
at processing.core.PApplet.handleDraw(PApplet.java:1400)
at processing.core.PApplet.run(PApplet.java:1328)
at java.lang.Thread.run(Thread.java:637)


thanks people
Re: Little Boring Erro
Reply #1 - Mar 12th, 2009, 12:52pm
 
Classical error:
int[] ia = new int[256];
will indeed create 256 ints initialized with 0, usable immediately.

objs[] sa1 = new objs[256];
will create 256 null references to yet to create objs instances. So any use of these null references will throw an NPE.
You have to add a loop to create 256 new instances of objs and assign them to the array slots.
Page Index Toggle Pages: 1