So i'm making a small project for school and im trying to get 3 random integers between 1 and 10 and put them in a array, it works but i want to have 3 unique numbers and thats the part wich i can't figure out really.
This is my code so far:
public static void main(String[] args) {
int[] randomGetal = genereerGetallen();
for (int i = 0; i < 3; i++) {
System.out.println(randomGetal[i]);
}
}
public static int[] genereerGetallen() {
int[] randomGetal = new int[3];
for (int i = 0; i < randomGetal.length; i++){
randomGetal[i] = (int)(Math.random() * 10);
}
return randomGetal;
}