K
KAR120C
I am trying to learn the requirements for the new Java Certification exam and
came across something that doesn't make sense to me. According to the JDK 1.
5 docs, java.text.DateFormat is an abstract class, yet it has a constructor,
DateFormat(). It also has a method, getDateInstance(int style), that returns
a static reference that can be used to call a non-static method as in theses
four lines from the same documentation:
To format a date for a different Locale, specify it in the call to
getDateInstance().
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE);
You can use a DateFormat to parse also.
myDate = df.parse(myString);
How can an abstract class have a constructor and how can a static reference
be used to call a non-static method?
Thanks
came across something that doesn't make sense to me. According to the JDK 1.
5 docs, java.text.DateFormat is an abstract class, yet it has a constructor,
DateFormat(). It also has a method, getDateInstance(int style), that returns
a static reference that can be used to call a non-static method as in theses
four lines from the same documentation:
To format a date for a different Locale, specify it in the call to
getDateInstance().
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE);
You can use a DateFormat to parse also.
myDate = df.parse(myString);
How can an abstract class have a constructor and how can a static reference
be used to call a non-static method?
Thanks