java 基础 获取运行时的类名方法名

获取方法名,通用

Thread.currentThread().getStackTrace()[1].getClassName()

非静态方法获取方法名

this.getClass().getName()

获取类名

Thread.currentThread().getStackTrace()[1].getMethodName()

猜你喜欢

转载自blog.csdn.net/csdn277/article/details/80800627