string - java Loop through variables with a common name -


i'm trying create 10 variables random numbers, beginning same word, like:
- foo1
- foo2
- foo3
- foo4

what i'm trying is:

for(int = 0; < 20; += i){   int name = int("foo" + i)   name = random(100, 500);   image(blabla, blabla, name);  //the blabla fixed coordinates }; 


cannot work.
guys know how solve this?

thanks in advance!

you use array.

an array variable holds multiple values.

int[] r = {1, 2, 3}; int x = r[0]; 

here processing array reference.

here how might in example:

pimage[] images = new pimage[20]; images[0] = loadimage(...); //..load rest of images  for(int = 0; < 20; += i){   image(blabla, blabla, images[i]); } 

you might want arraylist or hashmap classes.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -