I understand an abstract class as a class that cannot be instantiated.
Then why can it have a constructor?
1. the constructor should be protected. (public is useless since it's not gonna be instantiated. can only be called by subclasses' super())
2. use it to initialize abstract superclass fields.
"In any case, don't forget that if you don't define a constructor, then the compiler will automatically generate one for you (this one is public, has no argument, and does nothing)."
-http://stackoverflow.com/questions/260666
"If a constructor does not explicitly invoke a superclass constructor, the Java compiler automatically inserts a call to the no-argument constructor of the superclass. If the super class does not have a no-argument constructor, you will get a compile-time error.
Then why can it have a constructor?
1. the constructor should be protected. (public is useless since it's not gonna be instantiated. can only be called by subclasses' super())
2. use it to initialize abstract superclass fields.
"In any case, don't forget that if you don't define a constructor, then the compiler will automatically generate one for you (this one is public, has no argument, and does nothing)."
-http://stackoverflow.com/questions/260666
"If a constructor does not explicitly invoke a superclass constructor, the Java compiler automatically inserts a call to the no-argument constructor of the superclass. If the super class does not have a no-argument constructor, you will get a compile-time error.
Object does have such a constructor, so if Object is the only superclass, there is no problem." -http://docs.oracle.com/javase/tutorial/java/IandI/super.html