ArrayOutofBounds Exception
Alright I'm stumped, I'm trying to assign an int variable as the amount of array cells in an array. However, no matter how I assign the value the array takes a 0 as number of array cells and then gives an out of bounds exception. I think it has something to do with the array already setting its value before the variable is set to the intended value (I hope that makes sense).
here's the code:
main execution class:
Code:
//Create a new cells
Cell test = new Cell ();
Cell test1 = new Cell ();
//Configure the cells
test.ConfigureCell(20);
test1.ConfigureCell(20);
cell class:
Code:
private int wLength;
//Add array for the words that the cell will contain
private String words[] = new String [wLength];
...
public void ConfigureCell (int i){
number_of_cells += 1;
cell_fileName = "Cell_" + number_of_cells + ".txt";
i = wLength;
}
I'm still learning java so sorry if this is something fundamental that I'm missing.:(doh):