java - How do I get string values from my jtable? -


I have my table filled with strings and I am trying to reach them. I've tried '.getValueAt', but it gives me an error

The code is

  'if (dayOfTheWeek == "Thursday") {int thursdayCOUNT = 0; String [] THURSDAYSHOW = null; While (thursdayCOUNT & lt; 10) {THURSDAYSHOW [thursdayCOUNT] = (string) timetable.getValueAt (thursdayCOUNT, 3); ThursdayCOUNT = thursdayCOUNT + 1; } ''  

"error in thread" exception = "java.lang.NullPointerException my.UI.schedulerUI.jButton1ActionPerformed (schedulerUI.java1401) ''

You are currently starting to clear your string [] New string has to be done ["Some numbers go here"]

It seems that you use 10 as the repetition of your length , So that you can create an array:

Str [THRESDAYSHOW = New string [10];

It can easily be followed, here is a complete example with a loop to replace your loop:

  if (dayOfTheWeek.equals ("Thursday")) {string [] for THURSDAYSHOW = new string [10]; (Inti = 0; I & lt; THURSDAYSHOW.length; i ++ } {THURSDAYSHOW [i] = (string) timetable.getValueAt (i, 3);}}  

A last note, while comparing strings, .equals () .


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -