title: Read a String and an int from text ffile
body: <p>So i want to read a String and an int from a text file and it gets me java.lang.ArrayIndexOutOfBoundsException: 1</p>
  
  <pre><code>public class GetNameAndNumber{
      private ArrayList &lt;NameAndNumber&gt; list = new ArrayList &lt;NameAndNumber&gt;();
      BufferedReader buf = new BufferedReader(new FileReader("NameAndNumber.txt"));
      String linie = buf.readLine();
      while(true)
              {
              linie = buf.readLine();
              if(linie == null)
                  break;
              else
                  {
                  String split[] = linie.split(" ");
                  NameAndNumber nan = new NameAndNumber(split[0], Integer.parseInt(split[1]));
                  list.add(nan);
                  }
              }
  
  }
  </code></pre>
  
  <p>the "NameAndNumber" class has a String and an int</p>
  
  <p>and this is the text file:</p>
  
  <pre><code>John 1
  David 0
  Ringo 55
  </code></pre>
  
  <p>What i don't know is why this one gives me an error, but when i read 2 strings and then an int like </p>
  
  <pre><code>NameAndNumber nan = new NameAndNumber(split[0], split[1], Integer.parseInt(split[2])); - this "NameAndNumber" having two strings and an int
  </code></pre>
  
  <p>for a text file like</p>
  
  <pre><code>Johnny John 8
  Mathew John 0
  </code></pre>
  
  <p>it gives me no errors and stores the values correctly. why ?</p>