Notice
Recent Posts
Recent Comments
Link
반응형
목록Companion (1)
변명은 만개 결과는 한개

Companion class companion object 일반적인 클래스의 변수와 메소드를 직접 접근할 수 있도록 만들어주는것. 간단히 말하면 java의 static 형태로 접근이 가능한 변수와 메소드를 만들어주는것 class 내에 정의할 수 있음 Java 에서처럼 Class.TYPE 형태로 직접 접근 가능 static은 아님 // class 내에 직접 접근을 위한 함수와 변수 정의 class Sample { val name: String = "Name" companion object { val type: Int = 0 fun isTypeZero(): Boolean { return type == 0 } } } interface와 함께 사용 interface Base { val name: String f..
공부/Kotlin
2020. 11. 20. 20:20