0
The problem is the following I try to save the object in a List and what happens is that it saves the reference not the object someone can help me to solve this problem?
ArrayList<ModeloParcela> modeloParcelas = new ArrayList<ModeloParcela>();
for (int i = 1; i < quantidade; i++) {
ModeloParcela modeloParcela = new ModeloParcela();
calendarTemp.add(calendarTemp.MONTH, 1);
System.err.println(result[0]);
modeloParcela.setDataVencimento(calendarTemp);
modeloParcela.setValor(result[0]);
modeloParcelas.add(retorno(modeloParcela));
}
When I show the data of the list I see that the items are all repeated.
for (ModeloParcela v : modeloParcelas) {
System.err.println(format.format(v.getDataVencimento().getTime()));
}
could show the method return ???
– Thiago Luiz Domacoski
I edited and put how I’m showing the data.
– danilo pelusci
Not knowing what the return method does gets a little complicated.
– hugofsousa