lundi 13 novembre 2017

java.lang.ArrayIndexOutOfBoundsException: 1 >= 1

What is happening? the first time it runs everything goes well but if it is executed a second time it fails even if it meets the for condition:

private void actualizar_screen(){
        DefaultTableModel tabla = (DefaultTableModel) screen_table.getModel();
        int total_rows = tabla.getRowCount();
        int i=0;
        System.out.println("Total items: "+items);
        System.out.println("Total rows: "+total_rows);
        for(i=0;i<items;i++){
            System.out.println("i = "+i);
            tabla.removeRow(i);
        }
        System.out.println("Removidas "+i+" de items "+items);
}

the console shows the following

Total items: 1
Total rows: 1
i = 0
Removidas 1 de items 1

Total items: 2
Total rows: 2
i = 0
i = 1

java.lang.ArrayIndexOutOfBoundsException: 1 >= 1

Aucun commentaire:

Enregistrer un commentaire