Sign in to follow this  

How do I take a look at HashSet while debugging in Eclipse Expressions?

This topic is 2125 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here I am debugging a HashSet variable in Eclipse.

[img]http://i1207.photobucket.com/albums/bb464/tom_mai78101/Capture-14.png[/img]

I don't know where to look for the [color=#FF0000]contents[/color] of the HashSet. Could anyone help me out? Thanks in advance.

Share this post


Link to post
Share on other sites
The contents are contained in the 'table' member. However since the table is actually an array with the hash of the object used as the index in the array, it will may seem pretty sparsely populated, there will be alot of gaps between cells that actually have values.

Personally, I always override toString() and print all my members' values nicely in there. The debugger displays the return value of toString() in the lower pane, if you don't override it, it falls back to Object.toString() which just prints the Object's class (if my memory is correct) plus the address the object is stored at, which is (usually) not very helpful.

Edit:

While I'm thinking of it, you should also always override .equals() and .hashCode(), especially if you're putting those objects into a Set.

Share this post


Link to post
Share on other sites
Sign in to follow this