How is it possible for the abstract class Calendar to have a method that return its instance?
Hello guys! Yesterday I was studying a Java code and I saw the use of Calendar class for the first time. The material said that it was an abstract class and that there were other concrete class that inherited it (e.g. Gregorian calendar). But the material used the static method 'Calendar.getInstance()' that returns an instance for Calendar class and I cannot understand why this works since an abstract class cannot be instantiated directly. I tried to copy the behavior of the Calendar class creating an abstract class with the method getInstance returning its instance, but how I expected it generated an error. https://code.sololearn.com/cQK9JoJMj08B/?ref=app PS: Sorry for the text if it contains grammatical erros, I'm not good in english (I used Google Translator to helped me with it) - I'm brazilian 😄