title: Java ArrayList IndexOutOfBoundsException Index: 1, Size: 1
body: <p>I'm attempting to read a certain file in Java and make it into a multidimensional array. Whenever I read a line of code from the script, The console says:</p>
  
  <pre><code>Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
  </code></pre>
  
  <p>I know that this error is caused when the coding can't reach the specific index, but I have no idea how to fix it at the moment.</p>
  
  <p>Here is an example of my coding.</p>
  
  <pre><code>int x = 1;
  while (scanner.hasNextLine()) {
    String line = scanner.nextLine();
    //Explode string line
    String[] Guild = line.split("\\|");
    //Add that value to the guilds array
    for (int i = 0; i &lt; Guild.length; i++) {
      ((ArrayList)guildsArray.get(x)).add(Guild[i]);
      if(sender.getName().equals(Guild[1])) {
        //The person is the owner of Guild[0]
        ownerOfGuild = Guild[0];
      }
    }
    x++;
  }
  </code></pre>
  
  <p>**Text Document **</p>
  
  <pre><code>Test|baseman101|baseman101|0|
  Test2|Player2|Player2|0|
  </code></pre>
  
  <p>Other solutions, such as the one found here: <a href="https://stackoverflow.com/questions/9961292/write-to-text-file-without-overwriting-in-java">Write to text file without overwriting in Java</a></p>
  
  <p>Thanks in advance.</p>