Исключение в потоке "main" java.lang.arrayindexoutofboundsexception: 1
привет мне действительно нужна помощь
package moga.Utilities; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.HashMap; import moga.Data.Players; public class Configuration { public static int POPULATION_SIZE = 200; public static int GENERATIONS = 25; public static int TOTAL_PLAYERS; public static final float CROSSOVER_PROBABILITY = 0.7f; public static final float MUTATION_PROBABILITY = 0.03f; public static final long BUDGET = 6000000; public static final int OUTSIDERS = 5; public static final HashMap<Integer , Players> PLAYERS = new HashMap<Integer , Players>(); public static void generatePlayers()throws IOException { String csvFile = "src/IPL.csv/"; String line = ""; BufferedReader br = null; try { br = new BufferedReader(new FileReader(csvFile)); int index = 0; while ((line = br.readLine()) != null) { PLAYERS.put(index , new Players(index , line)); index++; } TOTAL_PLAYERS = PLAYERS.size(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } } }
package moga.Data; public class Players { public int playerId; public String playerName; public int isBatsman; public int isBaller; public int matchesPlayed; //Batting statistics public int totalRuns; public Double battingAvg; public Double battingStrikeRate; public int hundredScored; public int fiftiesScored; //Bowling statistics public Double bowlingAvg; public Double bowlingStrikeRate; public Double bowlingEconomyRate; public int wicketsTaken; public Double oversBowled; public int bowlingInnings; public long cost; public int isCaptain; public int isWicketKeeper; public int isOutsider; public Players(int id , String s) { this.playerId = id; String vals[] = s.split(","); this.playerName = vals[0]; this.isBatsman = Integer.parseInt(vals[1]); this.isBaller = Integer.parseInt(vals[2]); this.matchesPlayed = Integer.parseInt(vals[3]); this.totalRuns = Integer.parseInt(vals[4]); this.battingAvg = Double.parseDouble(vals[5]); this.battingStrikeRate = Double.parseDouble(vals[6]); this.hundredScored = Integer.parseInt(vals[7]); this.fiftiesScored = Integer.parseInt(vals[8]); this.bowlingInnings = Integer.parseInt(vals[9]); this.oversBowled = Double.parseDouble(vals[10])/6.0; this.wicketsTaken = Integer.parseInt(vals[11]); this.bowlingAvg = Double.parseDouble(vals[12]); this.bowlingEconomyRate = Double.parseDouble(vals[13]); this.bowlingStrikeRate = Double.parseDouble(vals[14]); this.cost = Long.parseLong(vals[15]); this.isCaptain = Integer.parseInt(vals[16]); this.isWicketKeeper = Integer.parseInt(vals[17]); this.isOutsider = Integer.parseInt(vals[18]); } }
import java.io.IOException; import org.jfree.ui.RefineryUtilities; import moga.Algorithm.GA; import moga.Algorithm.NSGA; import moga.DataStructures.Population; import moga.Utilities.Configuration; import moga.Utilities.GraphPlot; import moga.Utilities.Printer; public class App { public static void main(String args[])throws IOException{ Configuration.generatePlayers(); GraphPlot multiPlotGraph = new GraphPlot(); Printer.printInitialParentPopulationGeneration(); Printer.printGeneration(1); Population parent = NSGA.preparePopulation(GA.generatePopulation()); Population child = GA.generateChildren(parent); Population combinedPopulation; for(int generation = 1; generation <= Configuration.GENERATIONS; generation++) { Printer.printGeneration(generation + 1); combinedPopulation = NSGA.preparePopulation(GA.createCombinedPopulation(parent, child)); parent = NSGA.getChildFromCombinedPopulation(combinedPopulation); child = GA.generateChildren(parent); multiPlotGraph.prepareMultipleDataset(child, generation, "gen. " + generation); } Printer.printGraphPlotAlert(); Printer.render2DGraph(child); multiPlotGraph.configureMultiplePlotter("Batting Fitness ", "Balling Fitness ", "All Pareto"); multiPlotGraph.pack(); RefineryUtilities.centerFrameOnScreen(multiPlotGraph); multiPlotGraph.setVisible(true); Printer.printAlgorithmEnd(); } }
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at moga.Data.Players.<init>(Players.java:40) at moga.Utilities.Configuration.generatePlayers(Configuration.java:34) at moga.App.main(App.java:17)
я получил эту ошибку , что здесь происходит ?!!!
Что я уже пробовал:
я попробовал изменить номер индекса 0 на 1 или другой, а затем 0
String line="" to null все еще не работает