Skip to content
Advertisement

Getting the class name from a static method in Java

How can one get the name of the class from a static method in that class. For example

JavaScript

To put it in context, I actually want to return the class name as part of a message in an exception.

Advertisement

Answer

In order to support refactoring correctly (rename class), then you should use either:

JavaScript

or (thanks to @James Van Huis):

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement