Please help! This is driving me crazy. I don´t understand when populating TodosLosTurnos3x8Encontrados through an auxiliar variable called Turno3x8Aux in line
114 Turno3x8Aux.CtasEn3x8.add((3*(i-1)+k));
when k= 85 is the problem, it is supposed to add {1,2,3,4,5,6} only to the current TodosLosTurnos3x8Encontrados, however it changes all previous tuples (with values {1,2,3}) as soon as the line 114 is executed.!!
for (i=1;i<=NumSect3x8;i++){
Turno3x8Aux.TurnoDel3x8.InstanteIncialTurno=j.InstanteIncialTurno;
Turno3x8Aux.TurnoDel3x8.DuracionTotalTurno=j.DuracionTotalTurno;
Turno3x8Aux.TurnoDel3x8.ActividadTotalTurno=j.ActividadTotalTurno;
for (k=1;k<=3;k++){
//S_Ctas.add(3*(i-1)+k);
Turno3x8Aux.CtasEn3x8.add((3*(i-1)+k));
}
}
if (NumSect3x8>0){
TodosLosTurnos3x8Encontrados.add(Turno3x8Aux);
Source: Why is changing all data?