Skip to content

Instantly share code, notes, and snippets.

@dano1234
Last active August 29, 2015 14:07
Show Gist options
  • Save dano1234/ac97879f37f290720b1d to your computer and use it in GitHub Desktop.
Save dano1234/ac97879f37f290720b1d to your computer and use it in GitHub Desktop.
///Array way is commented out. ArrayList way is not.
DECLARE
ArrayList<Baby> manyBabyHolder;
//Baby[ ] manyBabyHolder;
CREATE
manyBabyHolder = new ArrayList<Baby>();
//manyBabyHolder = new Baby[1000];
ADD TO
manyBabyHolder.add(new Baby(int(random(width)), int( random(height)))); //birth
// manyBabyHolder[placeToAddInArray] = new Baby(int(random(width)), int( random(height))); //birth
// placeToAddInArray++;
ITERATE THROUGH
for (int i =0; i < manyBabyHolder.size (); i++) {
Baby thisBaby = manyBabyHolder.get(i);
//for (int i =0; i < manyBabyHolder.length; i++) {
// Baby thisBaby = manyBabyHolder[i];
// if (thisBaby != null) { //check to see if you put something in this part of the array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment