Java中静态方法返回类名

来源:互联网 发布:淘宝号哪里有卖的么 编辑:程序博客网 时间:2024/05/21 15:40
public static thisClassName=null; public static String getClassName() { if(thisClassName!=null)return thisClassName; try { throw new Exception(); } catch (Exception e) { StackTraceElement[] element=e.getStackTrace(); className=element[0].getClassName(); } return className; } 

[备忘]