Since abstract classes cannot be instantiated in java, I understand that the following code will not work:
However I noticed that the follwing code works fine, as in there is no compilation error:
I don't understand why. When we use the 'new' operator, are we not creating a new instance of the class, which in this case is not possible since 'DateFormat' is an abstract class? Yet the 2nd line of code works. Will be great if somone is able to explain. Thanks in advance.
The abstract class is not getting initialized but the array object to hold 6 references to a DateFormat type.
So the array members dfa,dfa,..dfa can refer to DateFormat child types (SingleDateFormat)
I have tried to put the abstract / array concept in a sample code below.