Why can't we use protected access modifier in Singleton class for Kotlin .
We can use the protected access modifier in Java class but when it comes to kotlin , this does not work out .
In Kotlin you cannot inherit from a singleton object, that's why protected modifier is useless, since protected modifier opens functions/properties for this class and subclasses only.
2
votes
You can't inherit from an object in Kotlin, so protected modifier does not make any sense. In Java, there is no such thing as singleton at language level, it's just a class with some specific logic
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more