samedi 13 mai 2017

how to make my random number unique and sort the number

i use collection shuffle but it doesn't work so far i go with this ...

import java.util.Random;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class TotoMachine {
public static void main(String[] args) {
    int[] array = new int[7];
Random rand = new Random();
for (int i = 0; i < array.length; i++)
    array[i] = rand.nextInt(65) + 1;
//Collections.shuffle()
Arrays.sort(array);
System.out.println(Arrays.toString(array));
}
}




Aucun commentaire:

Enregistrer un commentaire