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 3 of 3

Thread: How TreeMap does what it does.

  1. #1
    Member
    Join Date
    Jul 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default How TreeMap does what it does.

    I just tried to use the new version of TreeMap. Frustrated until I figured out that value V is a shallow copy. In my example, the problem cleared up when I used a different explicitly constructed iterator. In the same example, keyword K was a string literal inside each TreeMap.put(). This is not the way I will use in my intended "real" program. Is Keyword K also a shallow copy?

    TIA,


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How TreeMap does what it does.

    Map's don't hold copies, they hold references to the objects placed within the Map. I recommend you post an SSCCE demonstrating the problem you are experiencing and the behavior you want to shed more light on the subject.

  3. #3
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: How TreeMap does what it does.

    The 'new version' of TreeMap?

Similar Threads

  1. Basic treemap loop
    By Trunk Monkeey in forum Java Theory & Questions
    Replies: 3
    Last Post: May 1st, 2011, 10:11 AM
  2. TreeMap vs HashMap
    By Kerr in forum Collections and Generics
    Replies: 7
    Last Post: March 10th, 2011, 10:12 AM
  3. [SOLVED] TreeSet to TreeMap Problem
    By MoniD in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 25th, 2011, 01:27 PM
  4. treemap Duplicates
    By debug in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 6th, 2010, 11:52 AM
  5. Student TreeMap
    By raphytaffy in forum Algorithms & Recursion
    Replies: 6
    Last Post: March 2nd, 2010, 12:11 AM

Tags for this Thread