What is the use of 'object' keyword in Scala? How to create Singleton objects in Scala?
Answer Posted / Vishakha Dutt
The 'object' keyword in Scala is used to declare a singleton object, which is an object that can have only one instance. To create a singleton object in Scala, you simply define it using the 'object' keyword without creating any constructor or methods.nnHere is an example:n```scalanobject SingletonObject {n val someValue: String = "Hello World"n}n```
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers