2
Reply

What are companion objects in Scala?

    Scala classes cannot have static variables or methods. Instead a Scala class can have what is called a singleton object, or sometime a companion object.A singleton object is declared using the object keyword

    If a singleton object and class have same name then it is known as a Companion object. Campanion object and class should be defined in the same source file .