获取当前类名

 

获取类名:

1、在类的实例中可使用this.getClass().getName();适用于非静态方法,在static method中不能使用该方法;

2、在static method中使用方法:Thread.currentThread().getStackTrace()[1].getClassName();

获取方法名:Thread.currentThread().getStackTrace()[1].getMethodName();

获取代码行号:Thread.currentThread().getStackTrace()[1].getLineNumber();

posted @ 2020-02-04 17:50  摘珰  阅读(281)  评论(0)    收藏  举报