Getting the name of the currently executing method

前端 未结 22 2592
闹比i
闹比i 2020-11-22 03:33

Is there a way to get the name of the currently executing method in Java?

22条回答
  •  孤城傲影
    2020-11-22 04:32

    String methodName =Thread.currentThread().getStackTrace()[1].getMethodName();
    System.out.println("methodName = " + methodName);
    

提交回复
热议问题