title: Using an Array list to dictate the index of another Array list
body: <pre><code>public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      ArrayList &lt;SlotMachine&gt; machines = new ArrayList&lt;SlotMachine&gt;();
      System.out.print("How many machines are they playing?: ");
      int machinesNeeded = scan.nextInt();
      int machineCounter = 1;
      for (int i = 0; i &lt; machinesNeeded; i++) {
          machines.add(new SlotMachine());
          System.out.print("How often does machine # " + machineCounter + " pay its jackpot?: ");
          machines.get(i).setPayOutTime(scan.nextInt());
          System.out.print("How much is the jackpot for machine # " + machineCounter + ": ");
          machines.get(i).setPayOut(scan.nextInt());
          System.out.print("How many times has machine # " + machineCounter + " been played since paying out?: ");
          machines.get(i).setTimesPlayed(scan.nextInt());
          machineCounter ++;
      }
  
      ArrayList &lt;Integer&gt; machineOrder = new ArrayList&lt;Integer&gt;();
      machineOrder.add(3);
      System.out.print("Enter machine to use: ");
      System.out.println(machines.get(machineOrder.get(0)));
  </code></pre>
  
  <p>I want to use the values in the <code>machineOrder</code> list variable as an index to access machines value.
  Not sure what to do i keep getting the </p>
  
  <pre><code>Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 3, Size: 3   
  </code></pre>