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.
Page Index Toggle Pages: 1
Clearing arrays (Read 382 times)
Clearing arrays
Jan 19th, 2008, 4:08am
 
I have 4 arrays:

Red[] red = new Red[0];
Green[] green = new Green[0];
Yellow[] yellow = new Yellow[0];
Blue[] blue = new Blue[0];

And want to clear them when I click this space:

 if (mouseX >= 440 && mouseX <= 530 && mouseY >= 710 && mouseY <= 760) {
 // insert clear command
   }

What would I need to issue to clear the arrays? Thanks for your help in advance!
Re: Clearing arrays
Reply #1 - Jan 19th, 2008, 4:14am
 
Code:


Red[] red = new Red[0];
Green[] green = new Green[0];
Yellow[] yellow = new Yellow[0];
Blue[] blue = new Blue[0];

if (mouseX >= 440 && mouseX <= 530 && mouseY >= 710 && mouseY <= 760) {

red = new Red[0];
green = new Green[0];
yellow = new Yellow[0];
blue = new Blue[0]

}


This makes new objects and releases the old arrays from memory (if no other variable is referencing it).
Re: Clearing arrays
Reply #2 - Jan 19th, 2008, 4:37am
 
Arrgh, just left a redundant value in - thanks for your help!
Page Index Toggle Pages: 1