|
-
September 16th, 2009, 06:59 AM
#1
Help using insertElementAt
Hi Friends!!!
I'm newbe, and I'm trying to pass some element since a string to a vector. And I don't know if I using insertElementAt correctly. You can see de code:
s is a string
vc is a vector
for (x= 0; x <n; x++) {
c = s.codePointAt(x);
vc.insertElementAt(c,x);
}
Thanks!!!
-
September 16th, 2009, 08:06 AM
#2
Re: Help using insertElementAt
The code will compile and run, and the Vector will fill with the Integer character codes for the String characters, but why use Vector.insertElementAt when Vector.add would do just as well?
And what are you trying to achieve? Why put the characters into a Vector at all?
Also, you should use ArrayList instead of Vector, unless you have a particular reason for using Vector (e.g. multi-threading).
There are features that should not be used. There are concepts that should not be exploited. There are problems that should not be solved. There are programs that should not be written...
R. Harter
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|