A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
abstract - getInstance()
Joined: Feb 26, 2007
Mar 27, 2007 22:47:00
They say DateFormat is an abstract class. So, to instantiate, you do:
DateFormat d = DateFormat.getInstance();
Also, somewhere I read that abstract classes can't be instantiated. So, there is an anomaly here. Please throw soe light on it.
Also, if the 2nd statement is incorrect,
does the getInstance() mehtod apply to instantiate any abstract class?
Joined: Nov 24, 2005
Mar 27, 2007 22:58:00
What getInstance() does is basically to return a new SimpleDateFormat.
So [i]DateFormat d = DateFormat.getInstance();[i] would be equivalent to [i]DateFormat d = new SimpleDateFormat(...)[i] with default parameters.
All roads lead to JavaRanch
I agree. Here's the link:
subject: abstract - getInstance()
how do abstract classes like NumberFormat call the methods from their subclasses?
Simple Question regarding Abstract class
about abstract local classes
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014