Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

abstract class with static method that returns instance of itself?

807598Nov 2 2006 — edited Nov 2 2006
Hi,

I was looking at the Calendar class, and it is defined as a public abstract class. It has a static method called getInstance() which returns a Calendar object. How does an abstract class instantiate an object of itself? I tried to code an example doing that, but I get the error message:

MyClass is abstract; cannot be instantiated.

Can anyone provide a brief code example of how that works?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 30 2006
Added on Nov 2 2006
5 comments
417 views