#classes #scala
A singleton is a class that can have only one instance, i.e., object. You create singleton using the keyword object instead of class keyword.
If you want to change selection, open document below and click on "Move attachment"
Scala Classes & Objectsala
C:/>scala Test
Point x location : 20
Point y location : 30
Point z location : 20
C:/>
Singleton objects:
Scala is more object-oriented than Java because in Scala we cannot have static members. Instead, Scala has singleton objects. <span>A singleton is a class that can have only one instance, i.e., object. You create singleton using the keyword object instead of class keyword. Since you can't instantiate a singleton object, you can't pass parameters to the primary constructor. You already have seen all the examples using singleton objects where you called Scal Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details