Results 1 to 6 of 6
  1. #1
    victor8247 is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Post problem about vector

    hi guys, i'm confused with the problem about how to add a element to a vector?
    in my application, i called the method addElement to add a element to a vector, but no matter how many times i called the method, it just has only one element in the vector(the element is the last one i called the method addElement ). who can tell me why?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by victor8247 View Post
    hi guys, i'm confused with the problem about how to add a element to a vector?
    in my application, i called the method addElement to add a element to a vector, but no matter how many times i called the method, it just has only one element in the vector(the element is the last one i called the method addElement ). who can tell me why?
    It's very hard to say where your bug is without seeing your code. Perhaps you're adding the same Object to the Vector over and over again, but I'm just guessing. If you want more than just guesses, please give us enough information to allow us to be able to help you.

  3. #3
    victor8247 is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default this is my code for short

    <code>
    ...
    Vector<Integer> vector = new Vector<Integer>();

    here , get a Integer through a method, the method getLoc return type is Integer and return value is not fixed.

    call the method add

    vector.add(Integer);
    </code>

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by victor8247 View Post
    <code>
    ...
    Vector<Integer> vector = new Vector<Integer>();

    here , get a Integer through a method, the method getLoc return type is Integer and return value is not fixed.

    call the method add

    vector.add(Integer);
    </code>
    Please show real code with code tags.

  5. #5
    victor8247 is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default

    i've solved the problem. a little logic error, but thanks all the same.

  6. #6
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Please mark your thread solved with the thread tools at the top.

Similar Threads

  1. Vector Problem
    By osmaavenro in forum New To Java
    Replies: 14
    Last Post: 10-01-2010, 12:03 PM
  2. vector problem
    By shinichi90 in forum New To Java
    Replies: 9
    Last Post: 08-30-2010, 09:25 PM
  3. Problem with Vector
    By banhbaochay in forum New To Java
    Replies: 9
    Last Post: 04-01-2010, 06:01 PM
  4. Problem with vector
    By morghul in forum New To Java
    Replies: 3
    Last Post: 11-04-2009, 03:24 AM
  5. Vector problem
    By Ace_Of_John in forum New To Java
    Replies: 1
    Last Post: 01-27-2008, 09:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •