How could I use the following code with a HashSet?
This part of the code is used to assign a Manager to a worker, but I have a problem in the part that I mark with bold, because as I do it, it marks me as an error.
The Hashset I am using is: private HashSet<Empleado> empleados;
Original method with array:
for (int i = 0; i < empleados.length; i++) {
if (empleados[i] instanceof Directivo && empleados[i].getDNI().equals(DNI_directivo)) {
**d = (Directivo) empleados[i];**
}
}
e = new TrabajadorObra(d, DNI, nombre, cargo, nomina);
I try to do it this way for Hashset but I get an error.
for (Empleado e : empleados) {
if (e instanceof Directivo && e.getDni().equals(dni4)){
d = (Directivo) empleados;
}
e = new TrabajadorObra(d, DNI, nombre, cargo, nomina);