Array Index out of bounds
Hi, someone please help me trace out the problem because I tried everything still can't figure out where's the problem ...
: 7 Line 23
Code:
public class BookTest
{
public static void main(String args[])
{
Book bookArray[] = new Book[10];
String dataArray [][] = {{"Java","Davis","123","Wiley","London","25.50","Book"},
{"Where's my car", "Aston Kutcher","777","ORiely","Dallas","5.95","Fiction","123","456"},
{"Earthquakes","ChuckBerry","435","LABooks","LA","75.00","NonFiction"},
{"C++","Jones","456","Random","NY","10.75","Book"},
{"Doom","The Rock","918","Sans Publishing","LA","12.50","Fiction","1233","2323"},
{"Universal Studios","Walt","987","Dell","Houston","29.90","NonFiction"}};
for (int i=0; i<bookArray.length; i++)
{
bookArray[i]=new Fiction (dataArray[i][0],dataArray[i][1], Integer.parseInt(dataArray[i][2]), new Publisher(dataArray[i][3],dataArray[i][4]), Double.parseDouble(dataArray[i][5]),i, new Background(dataArray[i][7], dataArray[i][8]));
if (dataArray[i][6].equals("Fiction"))
bookArray[i]=new Fiction (dataArray[i][0],dataArray[i][1], Integer.parseInt(dataArray[i][2]), new Publisher(dataArray[i][3],dataArray[i][4]), Double.parseDouble(dataArray[i][5]),i, new Background(dataArray[i][7], dataArray[i][8]));
if (dataArray[i][6].equals("NonFiction"))
bookArray[i]= new NonFiction(dataArray[i][0],dataArray[i][1], Integer.parseInt(dataArray[i][2]), new Publisher(dataArray[i][3],dataArray[i][4]), Double.parseDouble(dataArray[i][5]),"History");
}// end of FOR Loop
for (int j=0; j<10;j++)
{
// bookArray[j].calculateTotalCharge((j+2)*3,Double.parseDouble(dataArray[j][5]));
System.out.println();
System.out.println();
System.out.printf(bookArray[j].toString());
} //end of for with j
} //end of main
} //end class BookTest