This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes abstract - getInstance() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "abstract - getInstance()" Watch "abstract - getInstance()" New topic
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
    
  11

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: abstract - getInstance()
 
Similar Threads
DateFormat question
how do abstract classes like NumberFormat call the methods from their subclasses?
Factory Methods
Simple Question regarding Abstract class
about abstract local classes