Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
String methodName = "";
try {
throw new Exception();
} catch (Exception e) {
StackTraceElement[] ste = e.getStackTrace();
methodName = ste[0].getMethodName();
}
System.out.println(methodName);
Since a method isn't an object, and without a special keyword: no.Isn't there a standard method to do that on Java 1.5?
public class Logger {
static void log(String className, String message) {
String methodName = "";
try {
throw new Exception();
} catch (Exception e) {
StackTraceElement[] ste = e.getStackTrace();
methodName = ste[1].getMethodName();
}
System.out.println("[" +className +"::" +methodName +"] " +message);
}
}