My query is about performance when traversing an ArrayList vs POJO, that is, if I take the data from the database and charge it to the ArrayList and then to a POJO:
Is it more efficient (at the processing level) to traverse the ArrayList (position [0], [1], ...) or POJO (pojo.nombre, pojo.lastname, ..)?
Example of the route of the ArrayList:
private List<Object[]> _listaClientes = new ArrayList<Object[]>();//creo el arrayList
public void cargaClientes(){
try{
_listaClientes = new ArrayList<>();
//obtengo los datos de la base de datos a través de un DAO
_listaClientes = ctrClientes.getData();
//Recorro el arrayList:
for(Object[] obj : _listaClientes){
System.out.println(obj[0]);//cedula
System.out.println(obj[1]);//nombre
//...
}
}catch(Exception e){
e.printStackTrace();
}
}
Example of the route of the POJO (Client):
private List<Cliente> listaClientes;
public void cargaClientes(){
try{
//obtengo los datos de la base de datos a través de un DAO
listaClientes = ctrClientes.getDataPojo();
//Recorro el POJO
Iterator<Cliente> itrCli = listaClientes.iterator();
while(itrCli.hasNext()){
Cliente cli = itrCli.next();
System.out.println(cli.cedula);//cedula
System.out.println(cli.nombre);//nombre
//...
}
}catch(Exception e){
e.printStackTrace();
}
}