I am trying to make an array that has different values in its cells, but for some reason it has repeating values. Where am I going wrong?
Here is my code:
package oefarray;
public class OefArray {
int[] getallenArray,differentArray;
public static void main(String[] args) {
OefArray arr = new OefArray();
arr.differentArray(10,10);
}
public void differentArray(int n, int max) {
differentArray= new int[n];
for (int i = 0; i < differentArray.length; i++) {
int value = (int) (Math.random() * max);
differentArray[i]= value;
for (int p: differentArray){
while (value == p){
value = (int) (Math.random() * max);
}
}
differentArray[i]= value;
System.out.println(differentArray[i]);
}
}
}