Let\'s say I have a base class named Entity. In that class, I have a static method to retrieve the class name:
class Entity {
public static
Your question is ambiguous but as far as I can tell you want to know the current class from a static method. The fact that classes inherit from each other is irrelevant but for the sake of the discussion I implemented it this way as well.
class Parent {
public static void printClass() {
System.out.println(Thread.currentThread().getStackTrace()[2].getClassName());
}
}
public class Test extends Parent {
public static void main(String[] args) {
printClass();
}
}