Индекс массива вне границ - Java

Я начал работать над своей первой Java-программой, которая представляет собой простой калькулятор, однако я получаю сообщение об ошибке, утверждающее, что мой массив вышел за границы. Я попытался отладить его, чтобы увидеть, где и почему это так, а также следуя коду на бумаге, оба из которых отображают результаты, которые я ожидаю и желаю. Поэтому я не вижу, где на самом деле проблема. Код не полный.

По словам отладчика, ошибка возникает в этой строке:

answer = outputNum.get(operationIndex) * outputNum.get(operationIndex+1);

Вот основная часть кода, который у меня сейчас есть:

   private class ButtonHandler implements ActionListener {

        /*
         * "outputNum" stores the numbers entered in order.
         * "orderOfOperations" stores all numbers in order after multiplication and division has been taken care of.
         * "operationList" stores the mathematical operations entered in order.
         * "currentNum" stores the most recently inputed numbers.
         * "currentString" stores the most recently inputed string of numbers.
         * "answer" stores temporary values and ultimately the answer to the inputed equation.
         * "start" stores whether or not the equals button has been pressed and a new equation has started.
         */
        ArrayList <Double> outputNum = new ArrayList <Double> (0);
        ArrayList <Double> orderOfOperations = new ArrayList <Double> (0);
        ArrayList <String> operationList = new ArrayList <String> (0);
        Double currentNum = 0.0;
        String currentString = "0";
        Double answer = 0.0;
        boolean start = false;

            public void actionPerformed(ActionEvent event) {

                if(event.getSource() == equalsBtn) {

                    /* Takes the current numbers string and convert it into a double.
                     * Let the order of operations be the inputed order for now.
                     * "operationIndex" to get values inside of the unchanging arrays "outputNum" and "operationList".
                     * "orderIndex" to get values inside of the changing array "orderOfOperations".
                     */
                    currentNum = Double.parseDouble(currentString);
                    outputNum.add(currentNum);
                    orderOfOperations = outputNum;
                    int operationIndex = 0;
                    int orderIndex = 0;

                        //Cycle through the mathematical operations that occur in the current equation.
                        for(String operation : operationList) {

                            if(operation == "x" || operation == "÷") {

                                // Multiply/divide numbers with the multiply/divide operations together.
                                if(operation == "x") {

                                    answer = outputNum.get(operationIndex) * outputNum.get(operationIndex+1);

                                }
                                else {

                                    answer = outputNum.get(operationIndex) / outputNum.get(operationIndex+1);

                                }

                                // Replace numbers multiplied/divided in the above statement with the new answer.
                                orderOfOperations.remove(orderIndex);
                                orderOfOperations.set(orderIndex, answer);
                                orderIndex++;

                            }

                            operationIndex++;

                        }

       ,             // Reset variables to the default values for the new equation.
                    System.out.println(orderOfOperations);
                    outputString = answer.toString();
                    answer = 0.0;
                    currentNum = 0.0;
                    currentString = "0";
                    outputNum.clear();
                    operationList.clear();
                    orderOfOperations.clear();
                    start = true;

                }
                else if(event.getSource() == additionBtn || event.getSource() == subtractionBtn || event.getSource() == multiplicationBtn || event.getSource() == divisionBtn) {

                    // Sets the text fields text blank if this is the start of a new equation.
                    if(start) {

                        outputString = "";
                        start = false;

                    }

                    /*
                     * Takes the current numbers string and convert it into a double.
                     * Add the mathematical operation and reset the current number.
                     */
                    currentNum = Double.parseDouble(currentString);
                    outputNum.add(currentNum);
                    operationList.add(event.getActionCommand());
                    currentString = "0";
                    outputString = String.format("%s%s", outputString, event.getActionCommand());

                }
                else {

                    // Sets the text fields text blank if this is the start of a new equation.
                    if(start) {

                        outputString = "";
                        start = false;

                    }

                    // Adds the button value to the text field text and the current number being inputed.
                    currentString = String.format("%s%s", currentString, event.getActionCommand());
                    outputString = String.format("%s%s", outputString, event.getActionCommand());

                }

            outputScreen.setText(outputString);

        }

    }

Вот сообщение об ошибке, которое я получаю:

Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at MainWindow$ButtonHandler.actionPerformed(MainWindow.java:141)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6414)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3275)
    at java.awt.Component.processEvent(Component.java:6179)
    at java.awt.Container.processEvent(Container.java:2084)
    at java.awt.Component.dispatchEventImpl(Component.java:4776)
    at java.awt.Container.dispatchEventImpl(Container.java:2142)
    at java.awt.Component.dispatchEvent(Component.java:4604)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4209)
    at java.awt.Container.dispatchEventImpl(Container.java:2128)
    at java.awt.Window.dispatchEventImpl(Window.java:2492)
    at java.awt.Component.dispatchEvent(Component.java:4604)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)
    at java.awt.EventQueue.access$400(EventQueue.java:82)
    at java.awt.EventQueue$2.run(EventQueue.java:676)
    at java.awt.EventQueue$2.run(EventQueue.java:674)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:690)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Ответы на вопрос(2)

Ваш ответ на вопрос