samedi 24 octobre 2015

android - Generate non-repetitive random numbers

I'm making a quiz, but I'd like all the question's to be random, but never repeat each other. I have a question id and I need to generate a random integer after each question. I have 6 questions. Id's are from 1-6.

I have checked different topics, but they haven't solved my problem.

This is the code I have right now, but it repeats:

Random rnd = new Random();
    Integer n = rnd.nextInt(6) + 1;

    qid=n;




Aucun commentaire:

Enregistrer un commentaire