kotlin
  • Kotlin
  • Variable
  • Function
  • First Class Citizen
  • High Order Function
  • Pure Function
  • Call by Value, Call by Name
  • Null Safe
  • Generic
  • Expression
    • if - else
    • when
    • try - catch
    • while
    • for
  • Class
    • abstract
    • constructor
    • Data Class
    • Default Value
    • enum
    • inheritance
    • interface
    • open
    • property
    • sealed
  • Kotlin Standard
    • let
    • with
    • apply
    • run
    • also
    • takeIf
    • takeUnless
    • use
    • repeat
  • Collections
    • Mutable
    • Immutable
    • Collections
    • Aggregate operations
      • any
      • all
      • count
      • fold
      • foldRight
      • fold vs foldRight
      • forEach
      • forEachIndexed
      • max
      • maxBy
      • min
      • minBy
      • none
      • reduce
      • reduceRight
      • sum
      • sumBy
    • Filtering operations
      • drop
      • dropLast
      • dropWhile
      • dropLastWhile
      • filter
      • filterNot
      • slice
      • take
      • takeLast
      • takeWhile
    • Mapping operations
      • map
      • mapIndexed
      • flatMap
      • groupBy
    • Elements operations
      • contains
      • elementAt
      • elementAtOrElse
      • elementAtOrNull
      • first
      • firstOrNull
      • indexOf
      • indexOfFirst
      • indexOfLast
      • last
      • lastIndexOf
      • lastOrNull
      • single
      • singleOrNull
    • Generation operations
      • partition
      • plus
      • minus
      • zip
      • unzip
    • Ordering operations
      • reversed
      • sorted
      • sortedBy
      • sortedDescending
      • sortedByDescending
Powered by GitBook
On this page
  1. Class

abstract

abstract class Person() { //open처럼 상속이 가능한 클래스가 된다

    abstract fun hello()    //abstract는 구현체를 가질 수 없다(open과의 차이점) {...} body 없음.

    open fun hi() {  -> //open 키워드가 상속받는 쪽에서의 오버라이드를 허용한다.
        println("hi") -> //open은 구현체를 갖는다.
    }

    fun ya() {  -> //open 키워드가 없다면 property나 function은 final 취급을 받아 오버라이드 불가.
        println("ya")
    }

}

class Bar : Person() {
    override fun hello {}    //abstract는 상속받은 쪽에게 구현을 강제한다.
}

//추상클래스의 인스턴스 생성
val foo = object: Person() {
    override fun hello() {
        ...
    }
}

abstract

open

override

O

O

implement

X

O

PreviousClassNextconstructor

Last updated 6 years ago