java - Why jTable change the order from an arraylist? -
java - Why jTable change the order from an arraylist? -
example hava arraylist. = {2,1.5, 1.51, 1.4} when fill columns. jtable show me this: an={1.4, 1.51,1.5, 2}
this code i've done.
void verdatos(){ string [] titulos= {"n","an","bn","pn","f(pn)"}; tabla=new defaulttablemodel(null,titulos); object []object = new object[6]; arraylist iteraciones = new arraylist(); iteraciones = biseccion.getiteraciones(); arraylist = new arraylist(); = biseccion.getan(); arraylist bn = new arraylist(); bn = biseccion.getbn(); arraylist fpn = new arraylist(); fpn = biseccion.getfpn(); collections.reverse(fpn); (int = 1; < iteraciones.size(); i++) { object[0] = ; object[1]= an.get(i); object[2]= bn.get(i); object[3]= iteraciones.get(i); object[4] = fpn.get(i) ; tabla.addrow(object); } jtblnumerica.setmodel(tabla); } bundle metododebiseccion; import java.util.arraylist; import javax.swing.joptionpane; /** * * @author hector guerrero */ public class biseccion { private static arraylist<string> = new arraylist<string>(); private static arraylist<string> bn = new arraylist<string>(); private static arraylist<string> iteraciones = new arraylist<string>(); private static arraylist<string> fpn = new arraylist<string>(); public static arraylist getan(){ homecoming an; } public static arraylist getbn(){ homecoming bn; } public static arraylist getfpn(){ homecoming fpn; } public static arraylist getiteraciones() { homecoming iteraciones; } public double raiz(funcion f, double a, double b, int nmax, double tolerancia) { double r = double.nan;// le damos united nations valor por defecto por siacaso no encontramos la raiz double c = a; int k = 0; system.out.print(b); iteraciones.add(0, double.tostring(c));// añade la colecion la primera iteraion an.add(0, double.tostring(a)); bn.add(0, double.tostring(b)); fpn.add(0, double.tostring(f.eval((a+b))/2)); if (f.eval(a) * f.eval(b) < 0) { while (math.abs(f.eval(c)) > tolerancia && k < nmax) { c = (a + b) / 2; if (f.eval(a) * f.eval(c) < 0) { b=c; }else{ a=c; } iteraciones.add(double.tostring(c));// añade la colecion la tietacion k an.add(0, double.tostring(a)); bn.add(0, double.tostring(b)); fpn.add(0, double.tostring(f.eval(c))); k++; } } if (k < nmax ) { r = c; } if (f.eval(a) * f.eval(b) > 0) { joptionpane.showmessagedialog(null,"f(a)f(b)>0", "no hay cambio de signo",joptionpane.error_message); r = double.nan; iteraciones.clear(); an.clear(); bn.clear(); fpn.clear(); } homecoming r; } public void borrarcoleccion() { iteraciones.clear(); an.clear(); bn.clear(); fpn.clear(); }
}
hera image enter link description here
java swing arraylist
Comments
Post a Comment