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: How to separate ArrayLists in memory?

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

    Default How to separate ArrayLists in memory?

    Dear All,

    My name is David and i have a problem with usage of ArrayLists.
    In my program i have defined two ArrayLists as follows:

    private ArrayList<Tour> ToursCR;
    private ArrayList<Tour> ToursUCC;

    In the constructor i initialize them as follows:

    this.ToursCR = new ArrayList<Tour>();
    this.ToursUCC = new ArrayList<Tour>();


    In a separate method i try to fill the ArrayLists:

    ToursCR.addAll(this.Cost_Per_Tour_Carrier());
    ToursUCC.addAll(this.Cost_Per_Tour_UCC());

    The output is was expecting was that ToursCR and ToursUCC would have different values. Which should also be the case because completely different values are obtained from the methods.

    However, after the ArrayList both should have been assigned values it appears that they both have the value of "ToursUCC".

    How can i make sure that each ArrayList contains the data it should contain?


    Kind regards


  2. #2
    Member
    Join Date
    Oct 2011
    Posts
    42
    My Mood
    Sneaky
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: How to separate ArrayLists in memory?

    This looks like an issue with what the two methods are returning. If you can't spot anything, try do a system.out of everything which is being returned by each of these methods and confirm it is different.

Similar Threads

  1. Replies: 1
    Last Post: May 25th, 2011, 07:55 AM
  2. updating SWT Slider from separate java class
    By ppmckee in forum AWT / Java Swing
    Replies: 0
    Last Post: April 14th, 2011, 03:23 PM
  3. how to separate this code in another class
    By Jhovarie in forum AWT / Java Swing
    Replies: 2
    Last Post: February 28th, 2011, 06:22 PM
  4. separate strings
    By ridg18 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: January 21st, 2011, 06:22 AM
  5. Memory Handling -de allocate memory in Java
    By 19world in forum Java Theory & Questions
    Replies: 4
    Last Post: June 15th, 2010, 04:05 AM