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 › How do you call one specific object in an Array
Page Index Toggle Pages: 1
How do you call one specific object in an Array (Read 761 times)
How do you call one specific object in an Array
Nov 3rd, 2009, 5:24pm
 
I want to be calling and working with one specific object in an Array List but how do I call it? For example:

for(int i=enemies.size()-1; i>=0; i--){
     Enemy peng = (Enemy) enemies.get(i);

to get the x variable out of a specific object that I've choosen do I say
peng.get(2).x ???

How would I write this?
Re: How do you call one specific object in an Array
Reply #1 - Nov 3rd, 2009, 10:38pm
 
this is an arraylist, right?

so now as you already defined your object. you can simply write peng.x
it always shows you the x value of the predefined object. (btw do i say, defined? how do i have to call that correctly in programming slang  Huh )

gettint it from an array, not arraylist. would look like this . peng[i].x

Page Index Toggle Pages: 1