打断点:
鼠标左键点击这里就会出现一个红点标志
(有各种形状,后续解释),就打上了一个断点。
启动:

对于没有运行过的程序,找到程序入口(main方法)前面的三角形
,鼠标右键启动
启动后,当我们的程序执行到断点程序处,就会出现调试界面,如下:

如果没有出现调试界面,那就是说明:根本没有执行断点处的程序。
先写一个简单的类来做测试,如下:
public class TestDemo {
public static int add(int a, String b) {
int c = Integer.parseInt(b);
return a + c;
}
public static char sub(int d, int e) {
char res = (char) Math.abs(d - e);
return res;
}
public static void main(String[] args) {
String b = "45";
int a = 13;
int sum = add(a, b);
int d = 17;
int e = 89;
char f = sub(17, 89);
}
}
接着,找个地方打上断点(确保程序会执行的地方)打上断点:

然后开始debug。
步过:

作用:
步入:

作用:
强制步入:

作用:
步出:

作用:
回退断点:

作用:
注意: 此回退仅限于,那个方法还没有调用完,否则是无法回去的再次debug那个方法的,只能重新启动debug。
跳到光标处

作用:
表达式计算:

作用:




恢复程序:

作用:

停止程序:

作用:
查看断点:

作用:

禁用断点:

作用:
给方法打上断点之后,当我们的debug到调用该方法的位置的时候,会直接跳转到方法处(直接Step Out就会跳转)。
断点右键可以进行设置:

添加异常断点流程:
作用:
右键断点,设置条件,只有当满足条件时,才会进入该断点程序停留,否则就直接往下面执行程序。
调试流程:
代码:
public static void main(String[] args) {
Stream.of(10, 30, 50, 90, 40)
.mapToLong(e -> e*e )
.filter(e -> e > 2500)
.forEach(System.out::println);
}
断点调试:


作用:
调试流程:
代码:
public static void main(String[] args) {
new Thread(() -> {
System.out.println();
System.out.println("thread1 is running");
StringBuilder sb = new StringBuilder(".");
for (int i = 0; i < 10; i++) {
try {
Thread.sleep(100);
System.out.print(sb.append(".").toString());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}, "thread1").start();
new Thread(() -> {
System.out.println();
System.out.println("thread22 is running");
StringBuilder sb = new StringBuilder(".");
for (int i = 0; i < 10; i++) {
try {
Thread.sleep(100);
System.out.print(sb.append(".").toString());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}, "thread22").start();
new Thread(() -> {
System.out.println();
System.out.println("thread333 is running");
StringBuilder sb = new StringBuilder(".");
for (int i = 0; i < 10; i++) {
try {
Thread.sleep(100);
System.out.print(sb.append(".").toString());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}, "thread333").start();
}
断点:


查看输出:

作用: