Q:

Random accessing array, how to skip duplicates?

I have an XML array that I access to pull a random question from. How would I go about making sure there is no duplicates pulled? My current code follows.
    private void getQuestion() {
    // TODO Auto-generated method stub

    res = getResources();
    qString = res.getStringArray(R.array.questions);

    rQuestion = qString[rgenerator.nextInt(qString.length)];

    tokens = new StringTokenizer(rQuestion, ":");
    wordCount = tokens.countTokens();
    sep = new String[wordCount];
    wArray = 0;
    while (tokens.hasMoreTokens()) {
        sep[wArray] = tokens.nextToken();
        wArray++;
    }

}

Any help would be appreciated.

A:

The Fisher-Yates shuffle is an algorithm that is more or less designed for this purpose.

A:

I figured it out. I switched it to
private void getQuestion() {
    res = getResources();
    qString = res.getStringArray(R.array.questions);
    arrayLength = qString.length;
    qTotal = arrayLength;

}

private void getRandom() {
    rnd = rgenerator.nextInt(arrayLength);
    rQuestion = qString[rnd];
    qString[rnd] = "used";
    seperate();

}

private void seperate() {
    if (rQuestion != "used") {
        tokens = new StringTokenizer(rQuestion, ":");
        wordCount = tokens.countTokens();
        sep = new String[wordCount];
        wArray = 0;
        while (tokens.hasMoreTokens()) {
            sep[wArray] = tokens.nextToken();
            wArray++;
        }
        qNumber++;
    } else {
        if (qNumber < qTotal) {
            getRandom();
        } else {
            startActivity(new Intent("com.example.END"));
        }
    }

}

It gets the array from resources, then pulls a random question from the array. It then sets that one to "used" and splits it. It also checks to see if the pulled question is "used, and if it is, it pulls another question. It also goes to the end game activity if all questions are "used"

