title: How do I define an array of Strings using a method?
body: <p>I wrote a method to encrypt messages (using CaesarCipher) and I want to use that method to encrypt one message with all possible 26 keys.
  So I want to iterate over each String array to define it.</p>
  
  <pre><code>public String[] getMessage(String message) {
      String[] newMessage = new String[26]; 
      int index = 0; 
      for (int k = 0; k &lt; message.length(); k++){
          newMessage[index] = encryptMessage(message, index);
          index+= 1; 
      }
      return newMessage;
  }
  </code></pre>
  
  <p>But I get an <code>ArrayIndexOutOfBoundsException</code>.</p>
  
  <p>What am I doing wrong?</p>