Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Scala, why does getInstance fail to work with GregorianCalendar?

Tags:

scala

java.util.GregorianCalendar.getInstance();

Works in Java

java.util.Calendar.getInstance();

Works in Scala

java.util.GregorianCalendar.getInstance();

Fails in Scala. getInstance is not a member of object java.util.GregorianCalendar

like image 414
deltanovember Avatar asked Sep 29 '11 04:09

deltanovember


1 Answers

There are no static in scala, rather there are in singleton objects and methods in them, and so they are not considered inherited, even when defined in java. getInstance is defined on Calendar. In java, calling it on GregorianCalendar does call the exact same method as calling it on Calendar. In scala, you have to call it on Calendar. (BTW, calling it on GregorianCalendar in java is rather misleading)

like image 148
Didier Dupont Avatar answered Oct 22 '22 03:10

Didier Dupont