I have an ArrayList that stores certain objects, but one of them is an ArrayList, the question is the next one to show a Jtable the names of the people and the biggest sale that the problem has made is that the sales are saved in an Arraylist
This is my code, it shows me the sellers but when calculating a bigger sale it shows me the same in all
public void mayorVenta(){
String matriz[][] = new String[vendedor.size()][3];
double v ;
for (int i = 0; i < vendedor.size(); i++) {
matriz[i][0] = vendedor.get(i).getCodigo();
matriz[i][1] = vendedor.get(i).getNombre()+" "+vendedor.get(i).getApellido();
for (int j = 0; j < vendedor.get(i).getVenta().size(); j++){
v = vendedor.get(i).getVenta().get(0).getValor_venta();
if(v < vendedor.get(i).getVenta().get(j).getValor_venta()){
v= vendedor.get(i).getVenta().get(j).getValor_venta();
}
matriz[i][2] = Double.toString(v);
}
}
tablaVendedores1.setModel(new javax.swing.table.DefaultTableModel(
matriz,
new String[]{
"Codigo","Nombre", "Mayor ventas Realizada"
}
));
}
To summarize a bit the Arraylist and Como to have an idea that each Arraylist keeps:
ArrayList<Vendedor> vendedor = new ArrayList<Vendedor>();
vendedor.add(new Vendedor("Codigo", "Nombre" ,ventas));
ArrayList<Ventas> ventas = new ArrayList<Ventas>();
ventas.add(new Ventas("producto", valorVenta, fecha);