This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

abstract - getInstance()

 
Lovleen Gupta
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic