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 › Re: Variable retrieval from a Class
Page Index Toggle Pages: 1
Re: Variable retrieval from a Class (Read 972 times)
Re: Variable retrieval from a Class
Sep 30th, 2009, 11:03pm
 
You can refer to a variable owned by a class like this:
className.variableName

--Ben
Re: Variable retrieval from a Class
Reply #1 - Sep 30th, 2009, 11:19pm
 
My fault I explained it incorrectly I need to retrieve variable information from the objects created by a class.
Re: Variable retrieval from a Class
Reply #2 - Sep 30th, 2009, 11:40pm
 
you should still be able to do it that way.
Re: Variable retrieval from a Class
Reply #3 - Oct 1st, 2009, 1:48am
 
...unless the properties were set as private within the class; in which case you'll either have to make them public or write getter methods for them.
Re: Variable retrieval from a Class
Reply #4 - Oct 1st, 2009, 4:36am
 
BenHem was a bit fuzzy on the terminology...
I would rewrite his answer as:

You can refer to an instance of a class (a variable of the type of your class) like:
instanceName.variableName

Eg.: class Ball
Instance: Ball oneBall = new Ball();
Usage: oneBall.speed
(not Ball.speed - unless speed is static, but that's another story...)
Page Index Toggle Pages: 1