Hello Everyone;
I have been trouble with putting Random numbers in an array for an 2 hours
My problem is ,yes I know that how I can put Random numbers in an array but, for example
my array length is 6 and I generated 1 to 6 random number and first index I putted; hovewer the program should not be replace array[index] to array[index+1] Here my code is shown how can I fix ? Really I need help thank you for your interests.
public static int[] randomDizi(int size) {
final int finalSize = size;
// int randomNumber;
int newArray[];
newArray = new int[finalSize];
for (int in = 0; in < finalSize; in++) {
if ((in+1) < finalSize) {
do {
newArray[in+1] = (int) (Math.random() * finalSize) + 1;
newArray[in] = (int) (Math.random() * finalSize) + 1;
if (newArray[in+1] != newArray[in]) {
break;
}
} while (newArray[in+1] == newArray[in]);
}
}
return newArray;