Java獲取當前運行方法所在的類和方法名

代碼以下:this

public void showClassAndMethod() {
        System.out.println(this.getClass().getSimpleName() + ":"
                + new Exception().getStackTrace()[0].getMethodName());
}
相關文章
相關標籤/搜索