
kelly 发布于:周四, 08/04/2016 - 14:13 ,关键词:
Eclipse编程中的Debug工具(即自动找错工具)的使用方法:
首先在Eclipse中编写一段代码以下边代码为例,看到代码左边的蓝条

找到int n=10,X=5,y=2;这行点击鼠标右键,

点击Toggle Breakpoint,点击后就会在int n=10,X=5,y=2;这行左侧位置出现一个小蓝点

然后在程序栏上点击小虫子图案(Debug)按钮

点击后会弹出以下对话框

问的是要不要更换画面点击“yes”

就到了下边的全新界面

其中区域A是写代码区域;区域B是显示变量值的区域;C区域是程序输出的位置
小箭头指到哪行就是接下来要执行的代码。点击图片中箭头位置名为(step over)程序就会向下继续读代码。其中H标黄色是表示H值相对原来值有变化了。程序完全执行完后点击step over后会出现以下:

不用管。点击Resume表示Debug完成。

点击Resume表示Debug完成出现下边对话框

那接下来怎么回到原来的位置,首先移动到程序最右边,在右上角显示目前在debug模式下,

点击它左边java按钮

就回到了Eclipse熟悉的编辑代码的页面。

可以通过右上角在两个界面来回切换。如果又上角没有Debug按钮了,点击java左边加号按钮

出现下边对话框

点击debug就回到了debug界面。
本质上debug和自己读代码作用一样;如果程序写不出来的时候用下debug就能找出是哪里出了问题。