我对编程很新;我的节目是一个电视节目调度器,我试图从我创建的时间表(时间表)中获取一个变量。错误发生在第6行。
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();
}
错误是
线程中的异常“AWT-EventQueue-0”java.lang.ArrayIndexOutOfBoundsException:9
在my.UI.SchedulerUI.jButton1ActionPerformed(SchedulerUI.java:1412)
答案 0 :(得分:0)
将String[] SATURDAYSHOW = new String[9];
更改为String[] SATURDAYSHOW = new String[10];
您的数组索引超出范围,这意味着您尝试添加的值多于数组可以物理保存的值。