声明:本文参考自极客学院
1、syso+Alt+/:System.out.println("");
2、syse+Alt+/:System.err.println();
输出红色的错误信息
package control;
import javax.swing.JFrame;
public class DebugTest {
public static void main(String[] args) {
System.out.println(123456);
System.out.println(true);
System.out.println("this is String debug info");
System.out.println(new JFrame() {
@Override
public String toString() {
// TODO Auto-generated method stub
return "This is a JFrame";
}
});
System.err.println("this is String debug info");
System.err.println();
}
}
3、选中代码块,右键Surround with -> try/catch block
添加try/catch异常处理
注意:e.printStackTrace();可以打印错误,最好不要删掉
4、左侧行号双击,设置断点。
然后Debug,开始调试。
resume下一步
5、快捷键
Windows下:
Ctrl+1 或 光标移到错误处按F2:快速修复
Ctrl+z:撤销操作
Ctrl+d:快捷删除行
Shift+enter:跳转光标到下一行
Ctrl+F11:运行
Alt+上键/下键:快速移动行
Ctrl+Alt+上键/下键:快速复制行
Ctrl+m:将当前窗口放大
Alt+/:代码提示和自动补全
Ctrl+/:快速注释
设置在Preferences->General->Keys可以设置和查看快捷键。