go to previous page   go to home page   go to next page        
String[] list = new String[5];


The array object has five cells.

Fixed-length Array

Once an array object has been constructed, the number of cells will not change. It must be constructed with a length that will accommodate all expected data. Unfortunately, sometimes this length is hard to determine in advance. Depending on the data, the program might need differents sizes each time it is run. It would be nice if there were a type of array that allowed you to keep adding data regardless of its original length.


Say that an array has been declared and has been completely filled with information:

String[] list = new String[3];
list[0] = "ant" ;
list[1] = "bat" ;
list[2] = "cat" ;

After running for a while, the program needs to add information to the array. Will the following statement make the array larger?

list = new String[5];