open class Person{
private val a = 1
protected val b = 2
internal val c = 3
val d = 10 // public by default
}
class Indian: Person(){
// a is not visible
// b, c, d is visible
fun test(){
print(b)
}
}
class TestClass{
// person.a, person.b are not visible
// person.c, person.d are visible
fun testing(){
var person=Person()
print(person.c)
}
}
open class Person{
private val a = 1
protected val b = 2
internal val c = 3
val d = 10 // public by default
}
class Indian: Person(){
// a is not visible
// b, c, d is visible
fun test(){
print(b)
}
}
기본값으로 public 이다 어디에서든 값이 보인다.
private 는 그 안에서만 값이 보인다.
protected 는 하위 class에서만 값이 보인다.
internal 은 같은 모듈에서는 값이 보인다.