jeudi 23 juin 2016

Insert a number to the random position in an array of random number

I'm developing a simple game to add 2 number and select a result in a gridview. But i'm only put a number to 1st or last position of my list's Array. How to add my result to the random position without give it an exactly index? Here is my code

  x=random.nextInt(11);
  a=a+x;

    for (int j=1;j<25;){
        int random=((int)(Math.random()*25))+1;
        if (!list.contains(random)){
            list.add (a+random);
            j++;

        }

    }




Aucun commentaire:

Enregistrer un commentaire