Can I prevent random numbers from repeating in a 2d array
Is there a way to Stop repeating random numbers in a 2d array?
I have a 2d array 5x3 and I need to prevent a random number from repeating in the middle column which is array[r]
Here's what I have...
public static void main(String args)
int MyArray = new int ;
OutputArray(MyArray); //method to display array
}//end of main
static void fillArray(int array)
for (int r=0; r<array.length; r++)
for (int c=0; c<array.length; c++)
array[r][c] = (int)(Math.random()*10000)%10+1;
}//end of column
}//end of row
}//end of fillArray
I can make the element at array not equal to array but this means alot of coding to ensure all scenarios in this row do not equal each other.
Is there an easy way?
Any help greatly appreciated.