1.

What Is Object In Scala? Is It A Singleton Object Or Instance Of A Class?

Answer»

Unlike Java, Scala has two MEANINGS about ‘object’. Don’t get confuse about this, I will explain it clearly. In Java, we have only one MEANING for object that is “An instance of a class”.

Like Java, the first meaning of object is “An instance of a class”.

VAL p1 = new Person("Scala","Java")
or 
val p1 = Person("Scala","Java")

Second meaning is that object is a keyword in Scala. It is USED to define Scala Executable programs, Companion Objects, Singleton Objects etc.

Unlike Java, Scala has two meanings about ‘object’. Don’t get confuse about this, I will explain it clearly. In Java, we have only one meaning for object that is “An instance of a class”.

Like Java, the first meaning of object is “An instance of a class”.

val p1 = new Person("Scala","Java")
or 
val p1 = Person("Scala","Java")

Second meaning is that object is a keyword in Scala. It is used to define Scala Executable programs, Companion Objects, Singleton Objects etc.



Discussion

No Comment Found