목록상속 (2)
변명은 만개 결과는 한개

클래스 상속(class inheritance) open class 코틀린은 class에 open 키워드를 붙이지 않으면 기본적으로 final 이다. 그러므로 클래스의 상속 을 하기 위해서는 open 키워드로 final 키워드를 제거해주어야한다 open class Empty(a: Int) class Sample(a: Int) : Empty() java View class 상속 ConstraintLayout 상속받는 코드를 예시로 생성자 연습 // secondary 생성자 활용 class CustomConstraintLayout( context: Context, attrs: AttributeSet?, defStyleAttr: Int) : ConstraintLayout(context, attrs, defSty..

Class 생성자 class 클래스이름 constructor(변수){ } 또한 아래와 같이 다중 생성자를 가질 수 있음 class Sample constructor(val name: String, val arg: Int) { constructor(name: String) : this(name, 0) } class 를 정의함과 동시에 오는 생성자를 primary constructor 라 부르고, 그 이외의 생성자들을 secondary constructor 라 부른다. primary constructor 아래와 같이 constructor 생략 가능하다 class Sample (val name: String, val age: Int) { ... } 자바 생성자와 다르게 변수에 대한 타입을 바로 가질 수 있으며..