Eclipse Java常用的輸出調試技巧和Eclipse中的使用技巧

聲明:本文參考自極客學院

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可以設置和查看快捷鍵。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章