| Author |
how to increase the size of an array
|
liu hao
Greenhorn
Joined: Oct 02, 2009
Posts: 9
|
|
help, how to increase the size of an array to store more objects? we are supposed not to use Arraylist.
thanks for suggestion.
regards
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16482
|
|
|
You can't change the size of an array. Create a new one and copy the data from the old one to the new one.
|
 |
Steve Luke
Bartender
Joined: Jan 28, 2003
Posts: 3026
|
|
|
You can't. Arrays have a fixed size. There are alternatives though, like creating a new array with the intended size, then copying the content from the original array to the new one. There are also APIs which make this easier (see the Arrays and System javadocs. You might not want to use them, though, if this is an assignment.
|
Steve
|
 |
Janeice DelVecchio
Saloon Keeper
Joined: Sep 14, 2009
Posts: 1611
|
|
|
There was a thread the same as this last week.... you should do a search
|
When you do things right, people won't be sure you've done anything at all.
|
 |
liu hao
Greenhorn
Joined: Oct 02, 2009
Posts: 9
|
|
|
thanks. i usually don't have much time online now .......
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Paul Clapham wrote:You can't change the size of an array. Create a new one and copy the data from the old one to the new one.
thanks
|
 |
 |
|
|
subject: how to increase the size of an array
|
|
|