-1

I am a novice in Scala. I am trying to code in Scala, Below is the syntax of how a program starts:

object demo
{
  //do your stuff..............
}

What is the Significance of that?? Is it like mother of all the classes defined???

Any help would be helpful.

Lifu Huang
  • 11,930
  • 14
  • 55
  • 77
mohan babu
  • 1,388
  • 2
  • 17
  • 35

1 Answers1

2

class is a definition, a description. It defines a type in terms of methods and composition of other types.

An object is a singleton -- an instance of a class which is guaranteed to be unique. For every object in the code, an anonymous class is created, which nherits from whatever classes you declared object to implement. This class cannot be seen from Scala source code -- though you can get at it through reflection.

Rishanth k
  • 56
  • 4