์ธํ„ฐํŽ˜์ด์Šค 1

[Java] ์ถ”์ƒํ™”์™€ ์ธํ„ฐํŽ˜์ด์Šค

Interface (์ธํ„ฐํŽ˜์ด์Šค) ? - ํ•˜๋‚˜ ์ด์ƒ์˜ ์ธํ„ฐํŽ˜์ด์Šค ๋ฉ”์„œ๋“œ๋ฅผ ํฌํ•จํ•˜๊ณ  interface ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ ์–ธํ•˜๋ฉฐ ์ผ๋ฐ˜ ๋ฉ”์„œ๋“œ๋ฅผ ํฌํ•จํ•  ์ˆ˜ ์—†์Œ - ์ธํ„ฐํŽ˜์ด์Šค ๋ฉ”์„œ๋“œ๋Š” ๋ฉ”์„œ๋“œ์˜ ์„ ์–ธ๋งŒ ์žˆ๊ณ  abstract ํ‚ค์›Œ๋“œ๋ฅผ ๋ช…์‹œ์ ์œผ๋กœ ์„ ์–ธํ•˜์ง€ ์•Š์•„๋„ ๋˜๋ฉฐ, ์‹ค์ œ ๊ตฌํ˜„์€ ์ƒ์† ๋ฐ›์€ ์ž์‹ ํด๋ž˜์Šค์—์„œ ์ด๋ฃจ์–ด์ง interface Car { public void drive(); } public class ElectricCar implements Car { public void drive() { System.out.println("์ „๊ธฐ์ฐจ ์ฃผํ–‰"); } } ์ธํ„ฐํŽ˜์ด์Šค์˜ ํ•„์š”์„ฑ ์ธํ„ฐํŽ˜์ด์Šค์—์„œ ์ธํ„ฐํŽ˜์ด์Šค ๋ฉ”์„œ๋“œ๋ฅผ ์„ ์–ธํ•˜๊ณ  ์ž์‹ ํด๋ž˜์Šค์—์„œ ์šฉ๋„์— ๋งž๊ฒŒ ์žฌ์ •์˜ํ•จ์œผ๋กœ์จ ๋‹คํ˜•์„ฑ์˜ ๊ธฐ๋ฐ˜์ด ๋˜๋ฉฐ ์ฝ”๋“œ ์žฌ์‚ฌ์šฉ์— ๋„์›€์„ ์คŒ ํด๋ž˜์Šค ..

JAVA 2024.01.08