java - Not going in for loop -


i have following code

arraylist<integer> analysis = new arraylist<>(); arraylist<integer> designinitialbuild = new arraylist<>(); arraylist<integer> production = new arraylist<>(); arraylist<integer> strategy = new arraylist<>(); arraylist<integer> testing = new arraylist<>(); system.out.println("jtablelength: " + jtable1.getrowcount()); for(int xn=0;xn==jtable1.getrowcount();xn++){    system.out.println(jtable1.getmodel().getvalueat(xn, 3).tostring());    switch(jtable1.getmodel().getvalueat(xn, 3).tostring()){             case "analysis":           analysis.add(xn);           break;       case "design & initial build":           designinitialbuild.add(xn);           break;       case "production":           production.add(xn);           system.out.println("production");           break;       case "strategy":           strategy.add(xn);           break;       case "testing":           testing.add(xn);           break;       default:           system.out.println("i broken");           break;     }  } system.out.println(production.size()); 

when debug code shows variable xn has value of -8, never goes loop , first "println" before loop did system.out.println("jtablelength: " + jtable1.getrowcount()); displays 48..... i'm confused.

the condition on for loop wrong. for loop execute while condition true. try less than:

for(int xn=0;xn < jtable1.getrowcount();xn++){ 

this way, loop keep executing if xn less row count, , stop xn reaches row count.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -