Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
How in the world do you get an “instance” of an abstract class? Well you don’t of course, this won’t work:
This WON’T work:
Instead, use the static “getInstance()” method:
You can’t get an instance of Calendar, but you can can get an instance of a concrete Calendar subclass.
Obviously you can’t get an instance of Calendar, because Calendar is abstract. But you’re still free to call static methods on Calendar, since static methods are called on the class, rather than on a particular instance. So you call the static getInstance() on Calendar and it gives you back... an instance of a concrete subclass. Something that extends Calendar (which means it can be polymorphically assigned to Calendar) and which—by contract—can respond to the methods of class Calendar.