| Author |
Increasing Array size
|
rajesh kumar rayavarapu
Greenhorn
Joined: May 16, 2007
Posts: 12
|
|
Hi, iam new to the java. How to increase the array size dynamically? means if i take arry[3]={0,1,2} and then i want insert 3 in the same arry.Please send to me i have faced this question in one of the interview. thans, rajesh
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 10043
|
|
you can't. once an array is declared, its size is fixed. you have the option of declaring a new array, copying over all the values, and re-assigning the reference, however. or you could use an arraylist instead.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
 |
|
|
subject: Increasing Array size
|
|
|