title: Java XMLDecoder reading file into arraylist and ArrayIndexOutOfBoundsException
body: <p>good day, Im trying to create a program that reads a XML file then puts it into an arrayList and displays each name. The output is blank, there no names appearing, how do read the objects in the file when its a string and how can I get the names of the XML into the array?</p>
  
  <pre><code>import java.beans.*;
  import java.io.*;
  import javax.swing.JOptionPane;
  import java.util.*;
  import java.lang.ArrayIndexOutOfBoundsException;
  public class ReadNamesFromXML
  {
      public static void main(String[] args)
      {
  
  
          try {
              XMLDecoder decoder = new XMLDecoder(new
                      FileInputStream("lab10.xml")); 
  
              ArrayList&lt;String&gt; names = new ArrayList&lt;&gt;(); 
              System.out.println(names); 
          }
          catch (FileNotFoundException e){
              JOptionPane.showMessageDialog(null,"Not found"); 
          }
          catch(ArrayIndexOutOfBoundsException e){
              JOptionPane.showMessageDialog(null,"Not found"); 
          }
      }
  }
  </code></pre>
  
  <p>XMl file: </p>
  
  <pre><code>&lt;java version="1.8.0_144" class="java.beans.XMLDecoder"&gt;
  &lt;string&gt;Harry&lt;/string&gt;
  &lt;string&gt;Ron&lt;/string&gt;
  &lt;string&gt;Hermione&lt;/string&gt;
  &lt;string&gt;Luna&lt;/string&gt;
  &lt;string&gt;Draco&lt;/string&gt;
  &lt;string&gt;Neville&lt;/string&gt;
  &lt;string&gt;Seamus&lt;/string&gt;
  &lt;string&gt;Ginny&lt;/string&gt;
  &lt;string&gt;Fred&lt;/string&gt;
  &lt;string&gt;George&lt;/string&gt;
  &lt;/java&gt;
  </code></pre>