Get the current class class name
when called in a non-static method
able to pass
this.getClass().getName();
method to get the class name of the current instance
when called in a static method
The static method cannot execute the above method because it is separated from the class instance.
Thread.currentThread().getStackTrace()[1].getClassName();
method to get the current class name
Get the current method name
able to pass
Thread.currentThread().getStackTrace()[1].getMethodName();
method to get the name of the currently called method
**Note: The **getStackTrace() method will return an array of StackTraceElement objects of the call stack, the first element of which is the Thread.getStackTrace() method itself, so the second element in the array is the real calling method, and you can use this method. Analogy to get the method called by the upper layer