Calling An Inherited Class Method From Java
问题 In Python, class methods can be inherited. e.g. >>> class A: ... @classmethod ... def main(cls): ... return cls() ... >>> class B(A): pass ... >>> b=B.main() >>> b <__main__.B instance at 0x00A6FA58> How would you do the equivalent in Java? I currently have: public class A{ public void show(){ System.out.println("A"); } public void run(){ show(); } public static void main( String[] arg ) { new A().run(); } } public class B extends A{ @Override public void show(){ System.out.println("B"); } }