I am fairly new to programming; my program is a television show scheduler and I'm trying to grab a variable from the timetable(schedule) I have created. The error is happening on the 6th line.
if (dayOfTheWeek=="Saturday"){
int saturdayCOUNT=0;
String[] SATURDAYSHOW = new String[9];
SATURDAYSHOW=null;
while (saturdayCOUNT<10){
SATURDAYSHOW[saturdayCOUNT] = (String) timetable.getValueAt(saturdayCOUNT, 5);
saturdayCOUNT = saturdayCOUNT+1;
}
test1.setText(SATURDAYSHOW[0]);
test2.setText(SATURDAYSHOW[1]);
test3.setText(SATURDAYSHOW[2]);
test4.setText(SATURDAYSHOW[3]);
test5.setText(SATURDAYSHOW[4]);
test6.setText(SATURDAYSHOW[5]);
test7.setText(SATURDAYSHOW[6]);
test8.setText(SATURDAYSHOW[7]);
test9.setText(SATURDAYSHOW[8]);
test10.setText(SATURDAYSHOW[9]);
showPopup();
}
The error is
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 9
at my.UI.SchedulerUI.jButton1ActionPerformed(SchedulerUI.java:1412)
Change String[] SATURDAYSHOW = new String[9];
to String[] SATURDAYSHOW = new String[10];
Your array index is out of bounds, meaning that you are attempting to add more values than the array can physically hold.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments