Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Using Vector, data get duplicated

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Using Vector, data get duplicated

    Hey,

    I really need help

    while using Vector and adding elements, I get this problem:
    I add the 1st element: OK
    I add the 2nd element: 2 elements in the vector, but the first element gets the value of the second element
    I add the 3rd element: the vector contains 3 elements, all have the value of the 3rd element
    ..and so on

    here is the source code (written only the essential not to make it complicated for you)

    public static void main(String[] args) throws IOException, InterruptedException {
    int[] x1,x2,x3;

    Vector<int[]> population= new Vector<int[]>(50);


    // initialize x1,x2,x3 from some function

    population.addElement(x1);
    population.addElement(x2);
    population.addElement(x3);


    }

    Thank you


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,254
    My Mood
    Hungover
    Thanks
    142
    Thanked 617 Times in 528 Posts

    Default Re: Using Vector, data get duplicated

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/41850-data-get-duplicated-vector.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting
    The problems with cross-posting

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. detect duplicated programs
    By pulsarsitra in forum Java Theory & Questions
    Replies: 0
    Last Post: January 13th, 2011, 10:54 AM
  2. Replies: 2
    Last Post: December 22nd, 2010, 08:21 AM
  3. [SOLVED] 2D Vector
    By nasi in forum Collections and Generics
    Replies: 2
    Last Post: May 6th, 2010, 01:42 AM
  4. String Vector
    By nasi in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 3rd, 2010, 11:45 PM
  5. vector
    By sriraj.kundan in forum Java Theory & Questions
    Replies: 8
    Last Post: August 12th, 2009, 10:17 AM