File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to increase the size of an array

 
liu hao
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 4181
21
IntelliJ IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Janeice DelVecchio
Saloon Keeper
Posts: 1802
12
Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was a thread the same as this last week.... you should do a search
 
liu hao
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. i usually don't have much time online now .......
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic