How can I get the class name from a static method? Code example:
public class MyClass{
public static void doSomething(){
// get here the name of the class (MyClass)
}
}
How can I get the class name from a static method? Code example:
public class MyClass{
public static void doSomething(){
// get here the name of the class (MyClass)
}
}
Best Answer
There's no "direct" method for this; the usual way to do this is to construct a stack trace and then parse it:
Example output: