62,614
社区成员
发帖
与我相关
我的任务
分享
public class Test {
public static void caller() {
function();
}
public static void function() {
System.out.println(new Throwable().getStackTrace()[1].getMethodName());
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Test.caller();
}
}
输出caller,因为我要知道调用function的函数的名字。