title: Problem with Decrement Operator in While Loop
body: <p>I'm trying to write a program that calculates the sum of all the numbers in a diagonal section of a multiplication chart (basically from row 12 column 1 of the array to row 1 column 12). The problem is, in the code the Rowcounter refuses to decrease after every loop while the Colcounter increases just fine. What am I doing wrong?</p>
  
  <pre><code>    public Integer  ComputeDiagonalSum(int multiplier)
  {
      Integer [][] MultiArray = new Integer[multiplier][multiplier];
      int RowCounter = MultiArray.length - 1;
      int ColCounter = 0;
      Integer DiagonalSum = 0;
  
      while(RowCounter &gt; 0)
      {
          int RowNumber = RowCounter + 1;
          //
          //Compute inner loop
          while(ColCounter &lt; MultiArray[multiplier - 1].length)
          {
              int ColNumber = ColCounter + 1;
              //Load each box in the current column of the current row
              MultiArray[RowCounter][ColCounter] = RowNumber * ColNumber;
              DiagonalSum += MultiArray[RowCounter][ColCounter];
              ColCounter++;
          }
        //doesn't work
          RowCounter--;
      }
      return DiagonalSum;
  }
  </code></pre>
  
  <p>Link to image of multiplication chart:
  <a href="https://www.google.com/search?client=ms-android-samsung-ga-rev1&amp;sxsrf=ACYBGNQo4QAYAF-MjmvCR4jcbz3RqDx0eg%3A1581776894027&amp;ei=_v9HXvKbAYilUoveveAE&amp;q=multiplication+chart+&amp;oq=multiplication+chart+&amp;gs_l=mobile-gws-wiz-serp.3..35i39j0i22i30.1455.2670..3471...0.0..0.765.1392.5-1j1......0....1.0tdlwHvu690#imgrc=jtyeYkOxpQT3CM" rel="nofollow noreferrer">https://www.google.com/search?client=ms-android-samsung-ga-rev1&amp;sxsrf=ACYBGNQo4QAYAF-MjmvCR4jcbz3RqDx0eg%3A1581776894027&amp;ei=_v9HXvKbAYilUoveveAE&amp;q=multiplication+chart+&amp;oq=multiplication+chart+&amp;gs_l=mobile-gws-wiz-serp.3..35i39j0i22i30.1455.2670..3471...0.0..0.765.1392.5-1j1......0....1.0tdlwHvu690#imgrc=jtyeYkOxpQT3CM</a>:</p>