Why my Model class data is incorrect?
List<DataMasterList> dataMasterLists = new ArrayList<DataMasterList>();
private void addMaster() {
for (int i = 0; i < 6; i++) {
DataMasterList dataMasterList = new DataMasterList();
dataMasterList.setMaster_code("000" + i);
dataMasterList.setProduct_name("name" + i);
dataMasterList.setAmount(4 + i + "");
dataMasterList.setUnit_price(10 + "");
dataMasterLists.add(dataMasterList);
Log.d("test1",dataMasterLists.get(i).getMaster_code()+" ");
}
Log.d("test2",dataMasterLists.get(0).getMaster_code()+" ");
}
Content of Log.d:
test1: 0000
test1: 0001
test1: 0002
test1: 0003
test1: 0004
test1: 0005
test2: 0005
Why does test2 = 0005
?
Why every value in dataMasterLists
is 0005
?