在 Eclipse IDE 中监视变量内容

如何同时观察多个变量(例如 TreeSet)的内容?我可以观察一个 TreeSet 的内容,在“ Variables”窗口中点击它,但是我不知道如何对多个变量进行这种操作。

131772 次浏览

你可以这样做。

添加 watchpoint并在调试时,您可以在变量选项卡下的 调试器窗口透视图中看到变量。 或者 Add System.out.println("variable = " + variable); and see in console.

You can add a 监视点 for each variable you're interested in.

A watchpoint is a special breakpoint that stops the execution of an application whenever the value of a given expression changes, without specifying where it might occur. Unlike breakpoints (which are line-specific), watchpoints are associated with files. They take effect whenever a specified condition is true, regardless of when or where it occurred. You can set a watchpoint on a global variable by highlighting the variable in the editor, or by selecting it in the Outline view.

可以使用“表达式”窗口: 在调试时,菜单窗口-> “显示视图”-> “表达式”,然后它就有地方可以键入需要查看内容的变量

And how about selecting the text you want to watch, and then using the shortcut "Ctrl + shift + I"