In order to support refactoring correctly (rename class), then you should use either:
MyClass.class.getName(); // full name with package
or (thanks to @James Van Huis):
MyClass.class.getSimpleName(); // class name and no more
More Related Contents:
- Why are static variables considered evil?
- Calling Non-Static Method In Static Method In Java [duplicate]
- Why is the Java main method static?
- Why isn’t calling a static method by way of an instance an error for the Java compiler?
- How can I get a resource content from a static context?
- Java synchronized static methods: lock on object or class
- Java: Static vs inner class [duplicate]
- Why doesn’t Mockito mock static methods?
- Are Java static initializers thread safe?
- private final static attribute vs private final attribute
- How to instantiate non static inner class within a static method?
- Can I override and overload static methods in Java?
- Why isn’t a qualified static final variable allowed in a static initialization block?
- Should a “static final Logger” be declared in UPPER-CASE?
- Java: Static Class?
- How do I create a static local variable in Java?
- Java Error: Cannot make a static reference to the non-static method
- When NOT to use the static keyword in Java?
- Java static serialization rules?
- Java static final values replaced in code when compiling?
- Is it possible to override a static method in derived class?
- Why we should not use protected static in java
- Closest Ruby representation of a ‘private static final’ and ‘public static final’ class variable in Java?
- How and where to use Static modifier in Java?
- When does static initialization happen?
- Behavior of static blocks with inheritance
- How to extend a final class in Java
- Static variables and multithreading in java
- Whats up with static memory in java?
- Difference between Dynamic and Static type assignments in Java