I'm doing a Java desktop app with the M.V.P architecture for now I'm simulating the database in an arrayList in a repository
public class RepositorioClientes {
private static ArrayList<Cliente> listaClientes;
public RepositorioClientes() {
this.listaClientes = new ArrayList<>();
}
public void setListaClientes(Cliente cliente) {
this.listaClientes.add(cliente);
}
public ArrayList<Cliente> getListaClientes() {
return this.listaClientes
}
}
the issue is that when I want to get that arrayList it returns it null.
That's where I call the repository to get the array list:
public class PresentadorTransferencias {
private VistaTransferencias vistaTransferencias;
private RepositorioClientes repositorioClientes;
public PresentadorTransferencias(VistaTransferencias vistaTransferencias) {
this.vistaTransferencias = vistaTransferencias;
this.repositorioClientes = new RepositorioClientes();
}
public void inicializarCombobox() {
for (Cliente cliente : repositorioClientes.getListaClientes()) {
vistaTransferencias.getDesdejComboBoxTransferencia().addItem(cliente.toString());
vistaTransferencias.getHaciajComboBoxTransferencia().addItem(cliente.toString());
}
}
}
My question is, how do I solve this problem in order to obtain the previously saved objects?