default, Primary, Secondary Constructor & Init block
If we don't specify any constructor then class has its own default constructor. Ex: val student = Student()
Constructor with class name parenthesis is primary constructor
Keyword Constructor used for secondary constructor. secondary constructor call primary constructor
After constructor Init block of chain will be executed
Lateinit
Kotlin save us from runtime error so it make sure that class properties are initialised.
Kotlin gives error if we don't initialize the class properties.
If we want to initialize later then lateinit keyword is used.
lateinit is var always
Class variable must be initialize whereas function's local variable can not be initialize
lateinit can not be used with primitive data types
lateinit wih string is fine
Getter & Setter↗️
For validation we can add setter
For alteration we can add getter
Default getter and setter is looks like the bottom part of snapshot
In setter we receive an argument in value variable and field variable refer as a actual property
In get only field property is used