I'm reading Head First Java, and in its chapter about constructor methods, it says that even abstract classes have constructor methods, which are also run (first) when a subclass's constructor method is called. I decided to test it out, but for some reason my code isn't behaving the way I expected.
I created two very simple classes.
But when I compile my classes and run >java January30 -- I never see the "I ran" text being printed out. That was going to be my way of proving that the constructor ran in the abstract superclass. Any idea what I'm doing wrong?
I created two very simple classes.
public class January30 extends January30abstract { public static void main(String[] args){ January30 me = new January30(); } } abstract class January30abstract { public void January30abstract(){ System.out.println("I ran"); } }
But when I compile my classes and run >java January30 -- I never see the "I ran" text being printed out. That was going to be my way of proving that the constructor ran in the abstract superclass. Any idea what I'm doing wrong?