Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 tom_mai78101   Members   -  Reputation: 577

Like
0Likes
Like

Posted 24 March 2012 - 07:24 AM

Here I am debugging a HashSet variable in Eclipse.

Posted Image

I don't know where to look for the contents of the HashSet. Could anyone help me out? Thanks in advance.

Sponsor:

#2 Matt328   Members   -  Reputation: 241

Like
0Likes
Like

Posted 24 March 2012 - 10:44 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS