appending to the end of array

A

azzamqazi

hi guys,
i am having a problem and was thinking if someone can help me. ok
here it goes. How do i append to the end of an array?? I mean if i have
an array of strings how do i append a new string at the end of the
array in another method. Thanks guys :)

PS i think it might have to do something wit stacks but not sure :)
 
K

Kenneth P. Turvey

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi guys,
i am having a problem and was thinking if someone can help me. ok
here it goes. How do i append to the end of an array?? I mean if i
have an array of strings how do i append a new string at the end of
the array in another method. Thanks guys :)

There is no way to increase the size of an array. You have to create a
new array however big you need it and then copy the old array into it.

If this is really what you want to do, of course.

If you you are regularly doing this on large arrays you will end up with
a very poorly performing implementation. You should look at using a
LinkedList or ArrayList. These are implementations of the List
interface of the collections API. This is really what you probably
want.
PS i think it might have to do something wit stacks but not sure :)

Hmm. Maybe in how you would implement one. Take a look at Stack too.

- --
Kenneth P. Turvey <[email protected]>
http://kt.squeakydolphin.com (not much there yet)
Jabber IM: (e-mail address removed)
Phone: (314) 255-2199
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDQGCli2ZgbrTULjoRAvD8AJ4kJ2lDTh3F/r4zxlzeXo8XOndcxwCg4ikj
eYSW1KmigHNUbrulKwTnUVc=
=AZn7
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top