samedi 4 avril 2015

Randomize in JAVA

I have problem with generate randomize number in loop.



Random rand = new Random();
public MyPanel(){
super();
setLayout(new BorderLayout());

for(int y = 0; y < 10; y++)
for(int x = 0; x < 20; x++){
int n = rand.nextInt(4); // it should be generate another n in each repeat of loop?
b[x][y] = new Baloon(x*25, y*25,n); // n means color of baloon, I need this to get balloons with randomize colors.
add(b[x][y]);
}
}


Sorry for my English, i don't know this language perfectly.





Aucun commentaire:

Enregistrer un commentaire