Javaを参考に、現在のクラスのクラス名を静的に知りたいです。A は B の親クラスです。現在のクラスのクラス名を含む静的文字列を A (親クラス) に保持したいのですが、この静的文字列が B (子クラス) で参照されている場合は、Bのクラス名。これは可能ですか?
例:
public class Parent {
protected static String MY_CLASS_NAME = ???
.
.
.
}
public class Child extends Parent {
public void testMethod() {
if (MY_CLASS_NAME.equals(getClass().getName())) {
System.out.println("We're equal!");
}
}
}