Note that there are some explanatory texts on larger screens.

plurals
  1. POGlobal variable resetting
    primarykey
    data
    text
    <p>I have a list of arrays that i want to update, but it gives "index out of bounds" error. I can't seem to find the error. Need a pair of fresh eyes.</p> <pre><code>Global.variables.add(new String[]{(String) jComboBox1.getSelectedItem(), jTextField2.getText(), jTextField3.getText(), (String) jComboBox2.getSelectedItem(), "Reservado"}); public void generateRandom() { for (int i = 0; i &lt; Global.variables.size()-1; i++) { System.out.println("Searching "+Global.variables.get(i)[0]+" in temp "+i); for (int j = 0; j &lt; temp.size()-1; j++) { System.out.println("Testing "+Global.variables.get(i)[0]+" with "+temp.get(j)+" "+j); if (Global.variables.get(i)[0].equals(temp.get(j))) { System.out.println("FOUND!"); Global.variables.get(i)[4] = String.valueOf(Double.parseDouble(Global.variables.get(i)[1]) + mt.nextGaussian() * Double.parseDouble(Global.variables.get(i)[2])); System.out.println(Global.variables.get(i)[0]+" = "+Global.variables.get(i)[4]); } } } } </code></pre> <p>Global.variables contain (name, median, std, distribution, "reserved"); temp contains the name of some variables. So I try to run through the variables list see if they are in <em>temp</em> and update the "reserved" field...however: It gives me error: </p> <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 4 </code></pre> <p>Probably something easy but i can't seem to find what it is.</p> <p><strong>Solved</strong>: I was initializing Global.variables on another place, so some variables actually have the 5th element but others don't. Thanks :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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