Get class name in a static way in Java 8 [duplicate]
问题 This question already has answers here : How to get the name of the calling class in Java? (12 answers) Closed 1 year ago . This is a follow up to more general and similar question/answers In Java 8 I can get class name called the method using new Exception String className = new Exception().getStackTrace()[1].getClassName(); But can I get class name in a static way? edit If I'm inside a different class's method and want to know the class called my method 回答1: Example for getting the class