eclipse - Not seeing a full stack trace from Java Error -


background: making simulator 1 of college classes , rather large project.

issue: however, whenever type "i" or "c" (details shown in code) arrayindexoutofboundsexception exception java.lang (not custom handler) without any stack trace, , therefore cannot locate problem.

photo: enter image description here

code:

 /**  * creates world , starts loop of commands  */ public void run() {     if(configfile == null) {system.exit(0);}     initworld();     if(world == null) {         system.out.println("unable read config file.");         return;     }     world.print();      scanner reader = new scanner(system.in);     string line = reader.nextline();     while(canrun()) {         if(line.equals("p")) {             world.print();         } else if(line.equals("c")) {             world.turn();             species.printinfo();             steps++;             if(steps % 50 == 0) {                 species.printsummary(50);             }         } else if(line.equals("r")) {             species.printstatus();         }          if(line.equals("i")) {             world.turn();             steps++;             if(steps % 50 == 0) {                 species.printsummary(50);             }         } else {             line = reader.nextline();         }     }     world.print();     species.printsummary(-1);     if(this.steps >= this.maxsteps)         system.out.println("simulation ended because turn limit reached.");     else if(getpopulationofworld() == 0)         system.out.println("simulation ended because of species died.");     else if(getchangesinpaststeps() == 0)         system.out.println("simulation ended because there no changes in last 50 turns."); }      public void turn() {     int cursteps = this.getsteps();     system.out.println("current steps: " + cursteps);      if(species.getdeaths().size() == cursteps) {         species.getdeaths().add(new arraylist<integer>());         for(int = 0; < species.getspecies().size(); i++) {             species.getdeaths().get(cursteps).add(0);         }     }     if(species.getbirths().size() == cursteps) {         species.getbirths().add(new arraylist<integer>());         for(int = 0; < species.getspecies().size(); i++) {             species.getbirths().get(cursteps).add(0);         }     }      system.out.println("begin turning!");     for(int = 0; < board.size(); i++) {         list<cell> row = board.get(i);         for(int j = 0; j < row.size(); j++) {             cell cell = row.get(j);             if(cell.getanimal() != null) {                 cell.getanimal().activity();             }             if(cell.getplant() != null) {                 cell.getplant().activity();             }         }     }     steps++; } 

try use try catch

public void run() { if(configfile == null) {system.exit(0);} initworld(); if(world == null) {     system.out.println("unable read config file.");     return; } world.print();  scanner reader = new scanner(system.in); string line = reader.nextline(); while(canrun()) { try {     if(line.equals("p")) {         world.print();     } else if(line.equals("c")) {         world.turn();         species.printinfo();         steps++;         if(steps % 50 == 0) {             species.printsummary(50);         }     } else if(line.equals("r")) {         species.printstatus();     }      if(line.equals("i")) {         world.turn();         steps++;         if(steps % 50 == 0) {             species.printsummary(50);         }     } else {         line = reader.nextline();     } } catch(exception e) {   e.printstacktrace(); // or print full stack trace on log file } } world.print(); species.printsummary(-1); if(this.steps >= this.maxsteps)     system.out.println("simulation ended because turn limit reached."); else if(getpopulationofworld() == 0)     system.out.println("simulation ended because of species died."); else if(getchangesinpaststeps() == 0)     system.out.println("simulation ended because there no changes in last 50 turns."); 

}


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -