-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from Seogeurim/Java
[Java] μΆμν΄λμ€μ μΈν°νμ΄μ€μ μ°¨μ΄
- Loading branch information
Showing
2 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# λΆλ‘ - μκ°ν΄λ³΄κΈ° | ||
|
||
> μμ±μ : [μκ·Έλ¦Ό](https://github.com/Seogeurim) | ||
<details> | ||
<summary>Table of Contents</summary> | ||
|
||
- [μΆμν΄λμ€μ μΈν°νμ΄μ€μ μ°¨μ΄](#μΆμν΄λμ€μ-μΈν°νμ΄μ€μ-μ°¨μ΄) | ||
|
||
</details> | ||
|
||
## μΆμν΄λμ€μ μΈν°νμ΄μ€μ μ°¨μ΄ | ||
|
||
Javaμλ μΆμ ν΄λμ€(`abstract`)μ μΈν°νμ΄μ€(`interface`)κ° μλ€. μ΄λ€ κ°κ°μ 무μμΌκΉ? | ||
|
||
#### μΆμ ν΄λμ€ | ||
|
||
μμμ ν΅ν΄μ μμ ν΄λμ€μμ μΆμ λ©μλλ₯Ό μμ±νλλ‘ μ λνλ ν΄λμ€μ΄λ€. μΆμ λ©μλλ₯Ό μ μΈνκ³ μ μΈλΆλ§ μμ±νλ©΄ ν΄λΉ ν΄λμ€λ₯Ό μμλ°μ μμ ν΄λμ€λ κ·Έ λ©μλλ₯Ό λ°λμ ꡬνν΄μΌ νλ€. | ||
|
||
```java | ||
abstract class AbstractClass { | ||
public abstract void AbstractMethod(); | ||
} | ||
``` | ||
|
||
#### μΈν°νμ΄μ€ | ||
|
||
μΈν°νμ΄μ€λ ν΄λΉ μΈν°νμ΄μ€λ₯Ό ꡬννλ λ€λ₯Έ ν΄λμ€λ€μκ² λμμ μ£Όλ λͺ©μ μΌλ‘ μ¬μ©λλ€. μΈν°νμ΄μ€λ μΆμ ν΄λμ€μ λ€λ₯΄κ² λ€μ€ μμ(ꡬν)μ΄ κ°λ₯νλ€. | ||
|
||
```java | ||
interface MyInterface { | ||
public abstract void λ©μλμ΄λ¦(); | ||
} | ||
``` | ||
|
||
μ΄λ κ² μΆμ ν΄λμ€μ μΈν°νμ΄μ€κ° 무μμΈμ§ μ μν΄λ³΄μμ λ μ΄λ° μλ¬Έμ΄ λ€ μ μλ€. λͺ μλ λ©μλλ₯Ό ꡬννλ€λ μ μμ λμ μ¬μ© μ©λκ° λΉμ·ν΄λ³΄μ΄λλ° μ κ΅³μ΄ μΆμ ν΄λμ€μ μΈν°νμ΄μ€λ‘ λλμ΄μμκΉ? μ΄ λμ λλ μ μ¬μ©νλ κ²μλ λ°λμ μ΄μ κ° μλ€. κ·Έ μ°¨μ΄μ μ λν΄ μκ°ν΄λ³΄μ. | ||
|
||
### μΆμ ν΄λμ€μ μΈν°νμ΄μ€μ μ°¨μ΄μ λ° μ¬μ© μ©λ | ||
|
||
#### μ¬μ© μλμ μ°¨μ΄ | ||
|
||
μΆμ ν΄λμ€λ **μμ**, μΈν°νμ΄μ€λ **ꡬν**ν΄μ μ¬μ©νλ€. μ¦ μ΄ λμ μμκ³Ό ꡬνμ΄λΌλ μ μμ κ·Έ μ©λκ° λͺ νν ꡬλΆλλ€. μμμ `is-a` κ΄κ³λ₯Ό, ꡬνμ `can-do` κ΄κ³λ₯Ό μλ―Ένλ€. Javaμμλ νλμ ν΄λμ€λ§ μμμ΄ κ°λ₯νκΈ° λλ¬Έμ ν΄λΉ ν΄λμ€μ **ꡬλΆ**μ μΆμ ν΄λμ€ μμμ ν΅ν΄ ν΄κ²°νκ³ , ν μ μλ **κΈ°λ₯**λ€μ μΈν°νμ΄μ€λ‘ ꡬννλ€. | ||
|
||
#### κ³΅ν΅ κΈ°λ₯ μ¬μ© μ¬λΆ | ||
|
||
λͺ¨λ ν΄λμ€κ° μΈν°νμ΄μ€λ₯Ό μ¬μ©ν΄μ ν΄λμ€ κΈ°λ₯λ€μ ꡬννλ€λ©΄ 곡ν΅μ μΌλ‘ νμν κΈ°λ₯λ€λ λͺ¨λ ν΄λμ€μμ μ¬μ μν΄μΌν κ²μ΄λ€. **곡ν΅λ κΈ°λ₯μ΄ νμν λλ μΆμ ν΄λμ€λ₯Ό μ΄μ©**ν΄ μΌλ° λ©μλλ₯Ό μμ±νκ³ , μμ ν΄λμ€μμ μ¬μ©ν μ μλλ‘ νλ κ²μ΄ νΈν κ²μ΄λ€. | ||
|
||
#### κ°κ°μ μ¬μ© μ©λ | ||
|
||
μΆμ ν΄λμ€μ μΈν°νμ΄μ€λ μ¬μ© μλμ κ³΅ν΅ κΈ°λ₯ μ¬μ© μ¬λΆμμ μ°¨μ΄μ μ κ°μ§κ³ μλ€. λμ κ°κΈ° λ€λ₯Έ μ±κ²©μ κ°μ§κ³ μκΈ° λλ¬Έμ μ΄λ€ μν©μμ μ΄λ€ κ²μ μ¬μ©ν΄μΌνλμ§ μκ°ν΄λ³΄κ³ μ¬μ©νλ κ²μ΄ μ€μν κ²μ΄λ€. | ||
|
||
- μΆμ ν΄λμ€ : λΆλͺ¨ ν΄λμ€μ κΈ°λ₯μ μ΄μ© λλ νμ₯νκ³ μΆμ λ μ¬μ© | ||
- μΈν°νμ΄μ€ : ν΄λΉ μΈν°νμ΄μ€λ₯Ό ꡬνν κ°μ²΄λ€μ λν΄ λμΌν λμμ΄ μ½μλμ΄μΌ ν λ |