Modify ArrayList object in a JTable [closed]

0

I have a Table and I fill it with objects from an ArrayList I want to know how I can modify the data that was already saved in the ArrayList and that the table presents them

    
asked by David Calderon 13.06.2016 в 00:53
source

1 answer

1

You can go through the ArrayList and update the information of any element you want.

With a List Any

ArrayList<SomeClass> someList = new ArrayList<SomeClass>();  

The list is searched for an element that meets the id of the object to be modified

for (int x=0; x< someList(); x++) {
    item = someList.get(x); // Obtener el elemento en un indice
    if ( item.get_id_attribute == id ){ // Si el id es del objeto buscado
       item.set_attribute = "value"   // Actualizar un atributo usando un metodo accesos para modificar la información 
    }
}
    
answered by 13.06.2016 / 01:54
source