Java使用註釋標記過時方法

package Test;

public class Test {

	@Deprecated
	public void oldMethod () {
		//過時方法示例
	} 
	
	public void newMethod() {
		//正常方法
	}
	
	public static void main(String[] args) {
		Test test = new Test();
		test.oldMethod(); //舊方法會顯示刪除線,提示方法已過時,但不影響正常使用
		test.newMethod();
	}

}

IDE中顯示效果:

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