Like in java and .net a class is a blue print for objects. Once we define class, we can create multiple objects from the class with the keyword new.
Fields
since field is var type after creating the object we can reassign with a different value to the field.
The image of the objects in memory might look like:Figure 1
It’s obvious; soap object cannot be reinitialized because the objects given that they are vals, not vars.
“public” in Java, you simply say nothing in Scala
”semicolon” at the end of a statement is usually optional
But, a semicolon is required if you write multiple statements on a single line:
Singleton Object
Scala is more unique and easy to use language than java.
Scala cannot have static members
Scala has an easy way to define singleton object. Like we defining a class in scala we can easily define an object.
Instead of the keyword “class” we use the keyword “object”
Hope you understood about classes and objects in scala. Next we will look into functional objects and methods.