CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Posts
    28

    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!!!

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    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 &#91;CODE]...your code here...&#91;/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
  •  





Click Here to Expand Forum to Full Width

Featured