I've an array of objects:
Tratam --> has String, int ect.. and a Date object.
I want to add to a ArrayList 3 identical objects of each with different values of Date..
I have scheduled the following code, but as result in the arraylist always add the objects with the last date.. For example: If the dates must be 3:05, 3:15 and 3:25, add the objects with the third value.
Does anyone know what I'm doing wrong?
Thanks in advance!!!
for(n=0;n<tam;n++){
addObj(arrayObj[n]);
}
public void addObj(Tratam trat){
Tratam [] arrayObj2 = new Tratam[3];
Date date=trat.getNextTime();
for(int n=0;n<3;n++){
arrayObj2[n]=trat;
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.SECOND, interval);
date=cal.getTime();
arrayObj2[n].setNextTime(date);
arrayListTrat.add(arrayObj2[n]);
}
}