public class MyClass {
public static void test() {
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
}
public static void main(String args[]) {
String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
System.out.println(methodName);
test();
}
}
/*
run:
main
test
*/