Java get current method

1. Get the current method stack. We usually use

StackTraceElement[] stes = Thread. currentThread(). getStackTrace();

To get the current method, remember that it is not flexible enough. Use the fixed index of array Stes (many on the Internet say so, please distinguish it clearly).

Let's see what the API says?

getStackTrace

public [] getStackTrace()
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>