As the title says, I am trying to create a second array based on an original array, but issuing the values that are repeated.
My problem is that the code does not work as I would expect, since whatever I do I can not generate the new array without repeating it successfully.
I thank you in advance.
Code:
String[] ape = new String[]{"Acevedo","Uribe","Osorio","Uribe","Acevedo","Correa","Milan"};
String[] nuevosApellidos= new String[ape.length];
String temp="";
int c=0;
for(int k=0;k<e;k++){
nuevosApellidos[c]= ape[k];
temp= nuevosApellidos[c];
List<String> iterador = Arrays.asList(nuevosApellidos);
if(k>1){
if(iterador.contains(temp)){
System.out.println("El apellido "+temp+" ya estaba en el arreglo");
if((k+1)<nuevosApellidos.length)nuevosApellidos[c]= ape[k+1];
nuevosApellidos[c]="Vacío";
}
}
c++;
}