title: Local variables referred from inner class must be final or effectively final
body: <p>Please have a look at the below code</p>
  
  <pre><code>private void displayInitialRevenue_Method() {
      //Get the dates from the combo
      String selectedCouple = revenueYearCombo.getSelectedItem().toString();
      if (selectedCouple.equals("Select Year")) {
          return;
      }
      String[] split = selectedCouple.split("/");
      //Related to DB
      double totalAmount = 0.0;
      //Get data from the database
      dbConnector = new DBHandler();
      dbConnector.makeConnection();
      DefaultTableModel model = (DefaultTableModel) initialRevenueTable.getModel();
      model.setRowCount(0);
      ResultSet selectAllDetails = dbConnector.selectAllDetails("SQL CODE ");
      try {
          if (selectAllDetails.isBeforeFirst() == false) {
              JOptionPane.showMessageDialog(null, "This table is empty");
          } else {
              while (selectAllDetails.next()) {
                  String clientName = selectAllDetails.getString("Client Name");
                  String providerName = selectAllDetails.getString("Provider Name");
                  Double amountInvested = selectAllDetails.getDouble("Invest_Amount");
                  //Update the table
                  SwingUtilities.invokeLater(new Runnable() {
                      public void run() {
                          Object[] row = {clientName, providerName, amountInvested};
                          model.addRow(row);
                      }
                  });
                  //Get the total
                  totalAmount = totalAmount + amountInvested;
              }
              //Add the sum
              SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      Object[] blankRow = {null};
                      model.addRow(blankRow);
                      Object[] row = {totalAmount};
                      model.addRow(row);
  
                  }
              });
          }
      } catch (SQLException sql) {
          JOptionPane.showMessageDialog(null, sql.getLocalizedMessage());
      }
  }
  </code></pre>
  
  <p>This entire method is running inside another thread. The UI updates are running inside <code>SwingUtilities.InvokeLater()</code>. However pls put attention to the below.</p>
  
  <pre><code>Object[]row = {totalAmount};
  model.addRow(row);
  </code></pre>
  
  <p>The variable <code>totalAmount</code> is not final and it cannot be final because it need to be calculated in the above <code>while loop</code>. Since it is not <code>final</code> I am unable to use it inside the <code>SwingUtilities.InvokeLater()</code> as the error says <code>Local variables referred  from inner class must be final or effectively final</code></p>