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 › Constructor question
Page Index Toggle Pages: 1
Constructor question (Read 693 times)
Constructor question
Jan 15th, 2007, 1:08pm
 
I've got a blank constructor for an object. It's out of TomC's code really. Since I haven't had any formal training in Java, I was wondering what it actually does and whether I've broken it:
Code:

Node{
float x,y,z;
ArrayList links = new ArrayList();
public Node(){
this(0.0f,0.0f,0.0f);
}
}

I'm guessing it just sets x,y,z to 0.0f. Am I right?

Does it not get confused if there are other properties in there?
Re: Constructor question
Reply #1 - Jan 15th, 2007, 3:53pm
 
that makes this:

Node n = new Node();

equivalent to:

Node n = new Node(0.0f, 0.0f, 0.0f);

so its actual function depends on what happens in the Node(x, y, z) version of the constructor.
Re: Constructor question
Reply #2 - Jan 15th, 2007, 4:23pm
 
Yeah, that makes things pretty clear. I've already got an (x, y, z) constructor so that works out pretty good for me. Thanks.
Page Index Toggle Pages: 1