I am new to Kotlin and I am confused between open
and public
keywords. Could anyone please tell me the difference between those keywords?
All classes
, methods
, and members
are public
by default BUT not open
Keyword open
in kotlin means "Open for Extension"
means if you want any class to be inherited
by any subclass or method
to be overriden in subclasses you have to mark as open
otherwise you will get compile time error
NOTE: abstract
classes or methods are open
by default you do not need to add explicitly.