| Author |
abstract - getInstance()
|
Lovleen Gupta
Ranch Hand
Joined: Feb 26, 2007
Posts: 63
|
|
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? Thanks.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
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.
|
[My Blog]
All roads lead to JavaRanch
|
 |
 |
|
|
subject: abstract - getInstance()
|
|
|