Why am I getting an error when I try to get a string from my table in a Jframe?

user4470149

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)

Feek

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.

edited at
0

Comments

0 comments
Login to comment

Related

Why am I getting these error messages when I try to view media files on my Android device?

Why am i getting this error when i try to answer my own dns request?

Why am I getting an error message when I try to deploy my Gatsby website?

Why am i getting this error when i try to add foreign keys on Invoice table?

Why am i getting error when i try to assign string to istringstream object in visual studio in c++?

Why am I getting an error when I try to get a response by id?

Python/Terminal - Why am I getting this error message when I try to get user input

Why when i generate an Error i am getting an String Error?

why I am getting error from the try condition?

Why am I getting an error when I try to print the contents of a file I am searching for?

Why am I getting a 403 error when I go to a site? Happens only from ONE of my computers

When I try to deploy my PHP application to Google App Engine, why am I suddenly getting a 400 error?

Why am I getting an error when I try to use ngrok to create a http tunnel for my local host 5000 for Twilio?

Why am I getting an error saying that my string is not an iterable?

Why am I getting a syntax error when trying to create a table?

Why am I getting an 404 Error from my POST request?

Why am I getting error C1900101 when I try to upgrade from Windows 7 to Windows 10?

Why am I getting an error for 'Column cannot be null' during my post api when I am passing a value from a html form

Why do I get an error (Notice: Undefined index) when I try to echo a value from my database?

Why am I getting a "destination path '.' already exists" error when trying clone from my webfaction server?

Why am I getting a type error when trying to use a struct from a header in my .c file?

Why do I get an Error when I try to rename a table after FROM?

Why am I getting these warnings when I try to installing Pycharm in my Pop!_OS?

Why I am getting 'Forbidden' when I try to login on my live codeigniter site?

Why am I getting this TypeError when I try to slice my Pandas DataFrame?

Why am I getting a NameError when I try to call my function?

Why am I getting a Segmentation fault when I try to add a new node to my linked list?

Why am I getting a NameError when I try to access an attribute in my class?

Why am I getting an 'undefined' when I try to call my function?