[Kotlin] ์ธํ„ฐํŽ˜์ด์Šค
ยท
๊ฐœ๋ฐœ ํƒ€์ž„์บก์Š/Kotlin
์ธํ„ฐํŽ˜์ด์Šค ์ธํ„ฐํŽ˜์ด์Šค๋Š” ์ถ”์ƒ ํด๋ž˜์Šค์™€ ๋น„์Šทํ•˜์ง€๋งŒ ๋‹จ์ผ ์ƒ์†๋งŒ ๋˜๋Š” ํด๋ž˜์Šค์™€๋Š” ๋‹ค๋ฅด๊ฒŒ ๋‹ค์ค‘ ๊ตฌํ˜„์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ์ธํ„ฐํŽ˜์ด์Šค์˜ ์„ ์–ธ interface Runnable { fun run() fun fastRun() = println("๋นจ๋ฆฌ ๋‹ฌ๋ฆฐ๋‹ค") } #์ถ”์ƒ๋ฉ”์„œ๋“œ๋Š” abstract ํ‚ค์›Œ๋“œ๊ฐ€ ํ•„์š”ํ•œ๋ฐ ์ธํ„ฐํŽ˜์ด์Šค์—์„œ๋Š” ์ƒ๋žต ๊ฐ€๋Šฅํ•˜๋‹ค. ์ธํ„ฐํŽ˜์ด์Šค๋Š” ๊ตฌํ˜„์ด ์—†๋Š” ๋ฉ”์„œ๋“œ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๊ตฌํ˜„๋œ ๋ฉ”์„œ๋“œ๋„ ํฌํ•จ ๊ฐ€๋Šฅํ•˜๋‹ค. ์ธํ„ฐํŽ˜์ด์Šค์˜ ๊ตฌํ˜„ class Human : Runnable { override fun run(){ println("๋‹ฌ๋ฆฐ๋‹ค") } } #์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•  ๋•Œ๋Š” ์ธํ„ฐํŽ˜์ด์Šค ์ด๋ฆ„์„ : ๋’ค์— ์ ๋Š”๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋ฏธ๊ตฌํ˜„ ๋ฉ”์„œ๋“œ๋ฅผ ์ž‘์„ฑํ•œ๋‹ค. ์ด๋•Œ override ํ‚ค์›Œ๋“œ๋ฅผ ๋ฉ”์„œ๋“œ ์•ž์— ์ถ”๊ฐ€ํ•œ๋‹ค. ์ƒ์†๊ณผ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ•จ๊ป˜ ๊ตฌํ˜„..