title: Why is the array's length not being updated, causing an index out of bounds error?
body: <p>It appears that the size of my 2D array, <code>EncryptedArr</code>, is not getting updated within the <code>encryptData</code> method.</p>
  
  <p>This method is meant to encrypt a string (given within the main method) into an integer array. In order to see if the loops are actually placing data into the array correctly, I need the size of the array to match the data going into it.</p>
  
  <pre class="lang-java prettyprint-override"><code>static void encryptData(String toEncrypt)
  {
     stringLength = toEncrypt.length()
     encryptedArr = new int[stringLength][stringLength]
     for (rowIndex = 0; rowIndex &lt;= stringLength; rowIndex++)
     {
        for (columnIndex = 0; columnIndex &lt; encryptedArr[rowIndex].length; 
                                                            columnIndex++)
        {
           while (indexOfString &lt;= stringLength)
           {
              charToEncrypt = toEncrypt.charAt(indexOfString)
              charValue = charToEncrypt;
              encryptedArr[rowIndex][columnIndex] += charValue;
              indexOfString++;
           }
        }
     }
  }
  public static void main(String[] args)
  {
     String thing = "1";
     encryptData(thing);
     System.out.println("Here is the array: "+ encryptedArr);
  }
  </code></pre>
  
  <p><code>charAt</code> is causing a "String Index Out Of Bounds" error that I believe is due to the size of the array not getting updated to match the size of the String being encrypted. The main method is supposed to print the array in its entirety. Both <code>EncryptData</code> and Main methods are above. Why is the code updating the array size not working, and what can be done to fix it?</p>