I have to go through a list of file and place all their words inside vectors. I made a list of vectors so that all the "files" are in the same place. However, when I try to add a word inside the first vector of the list it gives me an error "Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 0" I looked around to see how I could fix it but most of the questions related are about a simple ArrayList and not of ArrayList<Vector>. Here is my code:
public static ArrayList<Vector<String>> documents = new ArrayList<Vector<String>>(1000);
int i = 0;
for(String file : trainingDataA) //trainindDataA is an array with all the files
{
    numDocA++;  //number of documents it went through
    Document d = new Document(file);
    String [] doc = d.extractWords(docWords); //parses the file and returns an array of strings
            
    for (String w : doc)
        documents.get(i).addElement(w);  //here is where I get the error, I just want to add all the 
                                         //string of the array (file words) to the first vector of 
                                         //the list 
                                         //so that every file has its own vector with its own words
    i++;  
}
I would really appriciate any help.
 
     
    