Recipe 5.13 Assigning Values to Variables While Debugging

     

Recipe 5.13 Assigning Values to Variables While Debugging

5.13.1 Problem

You want to change the values of variables while debugging to run tests on those new values.

5.13.2 Solution

Just double-click a field or variable name in the Variables view, and enter a new value in the dialog that opens.

5.13.3 Discussion

The Variables view displays the currently available variables and their values, as you can see at upper right in Figure 5-23.

Figure 5-23. Debugging with the Variables view
figs/ecb_0523.gif

To change a variable's value, just double-click it, and enter a new value. For example, to change the value in loopIndex from 3 to 2 , double-click loopIndex in the Variables view, enter 2 in the dialog that opens (shown in Figure 5-24), and click OK.

Figure 5-24. Changing a variable on the fly
figs/ecb_0524.gif

Note, however, that monkeying with data in a running program can break your code.

5.13.3.1 Eclipse 3.0

In Eclipse 3.0, some Java types, such as collections and maps, can be displayed in a more compact and meaningful form using variable filters . These filters are controlled with a toggle button in the Variables view.

5.13.4 See Also

Recipe 5.12 on evaluating expressions.



Eclipse Cookbook
Inside XML (Inside (New Riders))
ISBN: 596007108
EAN: 2147483647
Year: 2006
Pages: 232
Authors: Steve Holzner

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net