How do I get the method name from within that method?

前端 未结 4 1872
天命终不由人
天命终不由人 2021-02-06 10:02

I am trying to create a function that returns the method name from within that method:

  public static String getMethodName(final int depth)
  {
    final StackT         


        
4条回答
  •  南旧
    南旧 (楼主)
    2021-02-06 10:21

    return ste[1+depth].getMethodName();
    

    If you change return statement as above, you would get immediate calling method name , of cource depth shoould be zero..

提交回复
热议问题