Calendar cal=Calendar.getInstance() We know that Calendar is an abstract class so it can't be instantiated. So how we can say that cal is an instance of Calendar???
Beginner Question I suppose. Thanks in advace.
Hi , yes Calendar is an abstract class and it is not possible to create object directly by invoking the constructors in Calendar class.
In this cal is not a object to Calendar class directly , it is a object to java.util.GregorianCalendar class. Hear GregorianCalendar is sub class to Calendar and it is not a abstract. In this above code we are handling the GregorianCalendar class object by using it's super class Calendar class reference variable.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.