Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

size of array

 
ming ming
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i add the size of an array when it reaches it maximum???

 
vinod balaji
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
declare the amount variable as static. then it works fine
 
ming ming
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to use a loop in the setTest method to make it auto increase the size of the array....but when i use a loop it will only show the first input....
any idea how to solve that?
 
Arno Reper
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
first of all, you could take a look how Sun did in the ArrayList source file.
Second, you make another array with for example twice the length of your full array and then you use arraycopy to transfert the data to the new one.

you could also do like that :

I hope it help,
Arno
[ May 26, 2006: Message edited by: Arno Reper ]
 
Arno Reper
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ps : its nicer to write that with a static field...
like :

arno
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic