Steve
Steve

Reputation: 2816

Eclipse Java Debugger: easier way see values in the debugger that are in nested collections?

I'm new to the debugger and Eclipse.

I have many situations where holder objects, POJOs, are put into collections and sometimes those collections are even put into other collections.

It becomes very cumbersome when debugging a loop to keep opening many tree nodes just to see the value of a particular variable, have it turn out not to be what I was looking, having to advance to the next step,then having to open up all of those tree nodes again.

I tried setting a "watch" but values that showed in the rest of the debugger didn't show there.

I'm not very familiar with debbugers so perhaps I am misunderstanding the concept of a watch.

In any event, is there an easy way to see a particular variable's value when that variable is nested in several collections or objects, such that I don't have to expand tree nodes each time I want to see it?

Upvotes: 2

Views: 284

Answers (1)

Ajk_P
Ajk_P

Reputation: 1874

Watch is what you're looking for and my personal favorite tool.

The only rule is, you can only watch variables in your context (i.e. global + local variables, wherever you are in the code)

So if you have a aCollection.get(i).bCollection.get(j).cCollection you can view this variable as long as you have access to aCollection in the current context.

If not check how you can get aCollection (how it is related to your current method).

If in one method aCollection is retreived from newVar.getCollection() and in another one you can retreive directly aCollection, then - you can make 2 variables to watch:

  1. aCollection.get(i).bCollection.(j).cCollection;
  2. newVar.getCollection().get(i).bCollection.get(j).cCollection;

This should make it able for you to view cCollection from both methods with relative ease

Upvotes: 1

Related Questions