What’s the difference between lazy and lateinit?
Lateinit | Lazy |
---|---|
It is late initialization | It is lazy initialization. |
It can be initialized from anywhere in the object | It can be initialized only from the lambda function. |
It can only be used for var type. | It can only be used for Val type. |
Multiple initializations are possible in lateinit. | Only a single initialization is allowed here. |
It is not allowed in properties of primitive types. | It is allowed on properties of primitive types. |
BY Best Interview Question ON 17 Aug 2020