简体   繁体   中英

What is the significance of “object” Keyword in Scala?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM