jeudi 16 novembre 2017

how do you get the outcome to have no duplicates [duplicate]

import java.util.Random;

public class Lucklip {
    public static void main(String[] args) {

        Random rn = new Random();
        int[] ticket = {0,0,0,0,0,0};

        for(int i =0; i < 6; i++)
        {
            int answer = 1+rn.nextInt(50);
            ticket[i] = answer;
            System.out.println(answer);
        }

        System.out.print("ticket is");
        for (int i=0; i< 6; i++){
            System.out.print(" " + ticket[i]);
        }
        System.out.println("");

    }
}




Aucun commentaire:

Enregistrer un commentaire