I'm think perhaps there is not a way to do this, but I thought it worth asking. I want to do something like the following:
public class Super {
public static String print() { System.out.println(new Super().getClass().getSimpleName()); }
public Super() {}
}
public class Subclass extends Super {
public Subclass() {}
public void main(String[] args) {
Super.print();
Subclass.print();
}
}
My hope is to get the Super.print() to show "Super" and Subclass.print() to show "Subclass". I don't see how to do this from a static context however. Thanks for the help.
I'm well aware that I can do this without static methods, and that I can pass a class into each method call. I don't want to do that as that requires redefining several static methods on many subclasses.