How do I order a linked list in java?

0

// I do not know where I am beginning the error I want to sort by product code in a table by applying the bubble method

public DefaultTableModel ordenar(){

   DefaultTableModel tabla = new DefaultTableModel(); 

    tabla.addColumn("Codigo");
    tabla.addColumn("Nombre-producto");
    tabla.addColumn("valor");


    est_productos reco1 = null;

    est_productos sig = new est_productos();
    Integer [] array = new Integer[3];   
    for(int i=0; i<getcon()-1; i++){

       for(int j=0; j<getcon()-1; j++){
       if(codigo3.getcodigo()<codigo3.getnext().getcodigo()){

       sig.setcodigo(reco1.getnext().getcodigo());
       reco1.setcodigo(reco1.getcodigo());
       reco1.setcodigo(sig.getcodigo());


          }


       tabla.addRow(array);
       }




    }
    return tabla;
}
    
asked by Jhon Ureta 13.08.2017 в 20:45
source

1 answer

-1

You never initialize variable reco1 :

   est_productos reco1 = null;
   //..

To avoid being thrown at you, the error should be:

est_productos reco1  = new est_productos();
 //...
    
answered by 13.08.2017 в 21:41