Here I am debugging a HashSet variable in Eclipse.
I don't know where to look for the [color=#FF0000]contents of the HashSet. Could anyone help me out? Thanks in advance.
How do I take a look at HashSet while debugging in Eclipse Expressions?
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement