Quote:
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]);
Error seems to be coming from this part of code.
Somewhere the line that you read from the file does not have the entries as expected. Issue is with item in bold here:
while ((line = br.readLine()) != null) {
PLAYERS.put(index , new Players(index , line));
Your code is not handling for exceptions and having basic checks. First thing, before blindly using the indexes after split in below line, you should check for the array size and if the count matches your expectation.:
String vals[] = s.split(",");
A simple
debugging would give you these details.
Some reference:
ArrayIndexOutOfBoundsException (Java Platform SE 7 )[
^]
Quote:
Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.