Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your question doesn't state if you want the two inputs to be linked in any way. If you do you should be using a <code>HashMap</code> (or you could use two ArrayLists if you find that easier).</p> <p>The method you currently have is not working. I'll explain below:</p> <pre><code>public void getRain() //if you create a method that adds something, it should be named addRain() instead { double[] rArray = new double[32]; //This creates a array with size 33 for(int c = 0;c&lt;rArray.length;c++) // here you create a loop that will run 33 times { rArray[1] = Integer.parseInt(""+dayEntryField); // This will input the value thats in the variable dayEntryField in index 1 of the array. //This is not what you want since it will overwrite the current value thats in index 1 each time. } } // End of method. Since you have added the value to an array that was created inside this method, the array will be removed by the garbage collector at this point. Hence your data will not be saved! </code></pre> <p>What you need to do:</p> <pre><code>//Create the list outside the method private ArrayList&lt;Double&gt; arr = new ArrayList&lt;Double&gt;(); public void addRain() // You could also design the method to take an array as parameter, and add the data to that list (which is normally what you do( { arr.add(dayEntryField); //altho, since adding element is a one-liner this could easily be done inside your listener. If you have your arraylist inside a class you will need a method tho. } </code></pre> <p>This is about as much help I can give you without seeing any more code. But remember:</p> <ol> <li>Use <code>ArrayList</code> over array since it's dynamic and is easier to work with </li> <li>Make sure that the arraylist is initalized outside the method (if you use a method to add the value)</li> <li>Make sure that the name of your methods corresponds to what they are doing</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload