Why do we instantiate Calendar Class(abstract) in Java

java, oop, static

Solution

Calendar cal = Calendar.getInstance();

Is not calling a constructor, it's just calling a (static) method that returns an instance of some subclass (of `Calendar`).

Problem

I am a beginner Java programmer, and I've been reading about the Calendar class. It's an abstract class and all of its methods are static, but it is used as follows: ``` Calendar cal = Calendar.getInstance(); ``` Where you use `cal` to call methods like: ``` cal.setTimeinMillis(day1); ``` I'm confused about this. When calling methods against a class, why do we need a reference variable and how is this legal for static methods?

Original source