Home > other >  In Kotlin language what is the difference between an internal member and a public member within an i
In Kotlin language what is the difference between an internal member and a public member within an i

Time:11-20

internal class Point {
    internal val x = 0
    public val y = 0
}

Since Point class is internal, it is only accessible from within the same module. Wouldn't that make both x and y also accessible only from within the same module? If so, what is the difference between using internal and public inside an internal class?

CodePudding user response:

It's a distinction without a difference. The difference is that the public property y will be gettable publicly, while x will not be. In terms of equivalent java, y would have a public getter method. But since the class itself is internal there is no value to y's getter, at least in a pure Kotlin environment.

  • Related