#classes #scala
in Scala we cannot have static members. Instead, Scala has singleton objects.
If you want to change selection, open document below and click on "Move attachment"
Scala Classes & Objectscompiled and executed, it produces the following result:
C:/>scalac Test.scala
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 <span>in Scala we cannot have static members. Instead, Scala has singleton objects. 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 obje Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details