Object in Scala

The keyword object in scala is used to define a singleton , in otherwords its a class with only one object and everybody uses that same object. This can be used for a lot of the utility classes.

In Java , you essentially have a to define a class with static object and you have to make the constructor private and then only expose a getobject or getinstance to return the single instance .

All this is avoided in scala by using the keyword object.

if you define a class with the same name as the object in the file , its called a companion object and the two can access each others private variable

https://docs.scala-lang.org/overviews/scala-book/companion-objects.html