The problem lies in the CVSParser class. I need to read the .CSV file then pass it off to the ArrayList<Club>
Example.csv
Team,W,D,L,GF,GA
Arsenal,24,7,7,68,41
Aston Villa,10,8,20,39,61
...
Club class
public Club(String team, int w, int l, int d, int GF, int GA) {
...
}
CSVParser class
public static ArrayList<Club> CSVParser(String file) throws IOException{
ArrayList<Club> Lists = new ArrayList<>();
try{
Scanner scanner = new Scanner(new FileReader(file));
scanner.nextLine();
while(scanner.hasNextLine()){
String line = scanner.nextLine();
//System.out.println(line);
/*will get ArrayIndexOutOfBoundsException: 0 error */
String[] splits = line.split(",");
Lists.add(new Club(splits[0], Integer.parseInt(splits[1]),Integer.parseInt(splits[2]),
Integer.parseInt(splits[3]), Integer.parseInt(splits[4]), Integer.parseInt(splits[5])));
}scanner.close();
}catch(FileNotFoundException e){
e.printStackTrace();
}
System.out.println(Lists);
return Lists;
FileReaderto yourScannerinstead of aFile?