I'm starting to work with List in Java, my problem is this, I'm trying to fill in a list of objects, the classes are the following: Class Changes:
public class Cambios {
private List<Cambio> cambios;
public List<Cambio> getCambios() {
return cambios;
}
public void setCambios(List<Cambio> cambios) {
this.cambios = cambios;
}
}
Change Class:
public class Cambio {
String idCard;
String idList;
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard;
}
public String getIdList() {
return idList;
}
public void setIdList(String idList) {
this.idList = idList;
}
}
I am trying to fill them in the following way through the set, but I do not know very well how the lists work, thanks in advance
Cambios cambios;
Cambio cambio;
List <Cambio> cambioLista = null;
for (int i=0; i<10; i++){
String idCard= "Valor de id" + i);
cambioLista.get(i).setIdCard(idCard);
cambios.setCambios(cambioLista);
}