I have two arrays, one with 20 random numbers and another with those same 20 numbers but WITHOUT the repeating numbers. In addition, the second array is sorted in ascending order. My intention is to print the numbers without repetitions but with the order that the 20 random numbers had. I hope you have explained me well. This is what I have for now. EDIT: The 20 numbers are ordered by keyboard. These 20 numbers are those contained in the first array
int[] entrada = new int[20];
This array I have duplicated to be able to compare it when extracting the repeated numbers in another method (I do not think it is necessary to put the method)
int[] duplicado = new int[20]
for (int i = 0; i<entrada.length; i++){
duplicado[i] = entrada[i];
}
And this is what I have tried to print only the numbers without repetitions and by the order that the user has entered ::
for (int i = 0; i<duplicado.length; i++){
int j = 0;
if(duplicado[i] == entrada[j]){
System.out.println(duplicado[i]);
}else{
j++;
}
}