What is the difference between open and public in Kotlin?
What is the difference between open and public in Kotlin?
The main difference between open and public in Kotlin is:
public is a visibility modifier that allows a class, function, or property to be accessed from anywhere. It is the default visibility if no modifier is specified.
open is not a visibility modifier, but rather a modifier that allows a class or member to be overridden in subclasses. By default, classes, functions and properties in Kotlin are final and cannot be overridden, unless marked as open.
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.